@types/socketty
TypeScript icon, indicating that this package has built-in type declarations

0.2.30 • Public • Published

Installation

npm install --save @types/socketty

Summary

This package contains type definitions for socketty (https://www.npmjs.com/package/socketty).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/socketty.

index.d.ts

declare var socketty: socketty.Socketty;

export = socketty;
export as namespace socketty;

declare namespace socketty {
    interface Socketty {
        /**
         * Connect to a socketty server.
         * @param url The server url
         * @param callback The callback to be run when the connection is open
         * @return A Socket
         */
        connect(url: string, callback: (socket: SockettySocket) => void): SockettySocket;

        /**
         * Create a socketty server.
         * @param httpServer The HTTP server to use
         * @return A socketty server
         */
        createServer(httpServer: any): SockettyServer;
    }

    interface SockettySocket {
        /**
         * Listen for an action.
         * @param action The action to listen to
         * @param callback A callback to be run when the action is fired
         */
        on(action: string, callback: (message?: any) => void): void;

        /**
         * Send an action, as well as an optional message.
         * @param action The action to send
         * @param message The message to send
         */
        send(action: string, message?: any): void;

        /**
         * Specify a callback to be run when the socket is disconnected.
         * @param callback The disconnect callback
         */
        disconnect(callback: () => void): void;
    }

    interface SockettyServer {
        /**
         * Specify a callback to be run when a new socket connects to the server.
         * @param callback The callback
         */
        connection(callback: (socket: SockettySocket) => void): void;
    }
}

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: none

Credits

These definitions were written by Nax.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/socketty

Weekly Downloads

9

Version

0.2.30

License

MIT

Unpacked Size

5.73 kB

Total Files

5

Last publish

Collaborators

  • types