This repository was archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Socket
Gentilhomme edited this page Aug 25, 2017
·
1 revision
µWebSockets Socket Proxy
| 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.
Await for a event with a timeout (in milliseconds). Should let us write simplified callstack in many situations.
Send a structured data event to the client.
socket.send('test',{
msg: 'hello world!'
});Send a raw message (with no structure parsing).
socket.sendRaw(Buffer.from('hello world!'));Join a room. room argument can be a String or a Room Object.
socket.join(RoomA);
// or: socket.join('RoomA');Leave a room. room argument can be a String or a Room Object.
socket.leave(RoomA);
// or: socket.leave('RoomA');Close the socket.
socket.close();