Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.
Gentilhomme edited this page Aug 25, 2017 · 1 revision

Socket

µWebSockets Socket Proxy

Properties

name type
ws original uWebSocket socket
id String
rooms Set

id is a time-based string generated by the npm library 'uuid'

Socket have a static property namned DEFAULT_GET_TIMEOUT set to 5000ms. Update if you want to update the default timeOut of Socket.get method.

Methods

get(eventName,timeOutMS)

Await for a event with a timeout (in milliseconds). Should let us write simplified callstack in many situations.

send(event,data)

Send a structured data event to the client.

socket.send('test',{
    msg: 'hello world!'
});

sendRaw(buffer)

Send a raw message (with no structure parsing).

socket.sendRaw(Buffer.from('hello world!'));

join(room)

Join a room. room argument can be a String or a Room Object.

socket.join(RoomA); 
// or: socket.join('RoomA');

leave(room)

Leave a room. room argument can be a String or a Room Object.

socket.leave(RoomA); 
// or: socket.leave('RoomA');

close()

Close the socket.

socket.close();

Events

close -> void

Clone this wiki locally