Skip to content

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.

// Server
export function streamNumbers(socket: Socket<number>) {
setInterval(() => {
if (!socket.send(Math.random())) clearInterval(interval);
}, 1000);
}
// Client
api.streamNumbers(num => console.log(num));

T

Data type sent through the socket

virtualSocketId: number

Defined in: server.ts:446

send(data): any

Defined in: server.ts:453

Sends data to the client.

T

Data to send (automatically serialized)

any

true if sent, false if socket is closed


toString(): string

Defined in: server.ts:466

string