Socket
Defined in: server.ts:444
Server-side socket for pushing data to a client. Server functions with Socket<T> parameters
receive client callbacks on the client side.
Example
Section titled “Example”// Serverexport function streamNumbers(socket: Socket<number>) { setInterval(() => { if (!socket.send(Math.random())) clearInterval(interval); }, 1000);}
// Clientapi.streamNumbers(num => console.log(num));Type Parameters
Section titled “Type Parameters”T
Data type sent through the socket
Properties
Section titled “Properties”virtualSocketId
Section titled “virtualSocketId”virtualSocketId:
number
Defined in: server.ts:446
Methods
Section titled “Methods”send()
Section titled “send()”send(
data):any
Defined in: server.ts:453
Sends data to the client.
Parameters
Section titled “Parameters”T
Data to send (automatically serialized)
Returns
Section titled “Returns”any
true if sent, false if socket is closed
toString()
Section titled “toString()”toString():
string
Defined in: server.ts:466
Returns
Section titled “Returns”string