UNPKG

@enonic-types/lib-websocket

Version:

Type definitions for lib-websocket.

58 lines (57 loc) 1.42 kB
/** * Websocket functions. * * @example * var webSocketLib = require('/lib/xp/websocket'); * * @module websocket */ declare global { interface XpLibraries { '/lib/xp/websocket': typeof import('./websocket'); } } /** * Add an id to a socket group. * * @example-ref examples/websocket/addToGroup.js * * @param {string} group Group name. * @param {string} id Socket id. */ export declare function addToGroup(group: string, id: string): void; /** * Remove an id from a socket group. * * @example-ref examples/websocket/removeFromGroup.js * * @param {string} group Group name. * @param {string} id Socket id. */ export declare function removeFromGroup(group: string, id: string): void; /** * Send message directly to a socket id. * * @example-ref examples/websocket/send.js * * @param {string} id Socket id. * @param {string} message Message as text. */ export declare function send(id: string, message: string): void; /** * Send message to all sockets in group. * * @example-ref examples/websocket/sendToGroup.js * * @param {string} group Group name. * @param {string} message Message as text. */ export declare function sendToGroup(group: string, message: string): void; /** * Get number of all sockets in group. * * @example-ref examples/websocket/addToGroup.js * * @param {string} group Group name. */ export declare function getGroupSize(group: string): number;