0.3.14 • Published 8 years ago
v6-ws v0.3.14
WebSocket server
Simple WebSocket server with rooms, clients timeout and namespace.
Server side: SocketServer Client side: default websocket
Example
var Server = require('v6-ws').SocketServer;
wss = new Server({port: 8080, path:'/ws', pingTimeout:10000, pingInterval:5000});
wss.init(function(error){});
wss.on('connection', handler)
function handler(ws) {}API
SocketServer(opts:Object)
Options:
pathnamespace websocket server for connection, default is '\ws'portlistening port, optional, default is 8080serveroptional web serverhttpsoptional https flag, default is falsecertpath to ssl certificate for https, optionalkeypath to ssl key for https, optionalpingTimeoutdefault is 60000 mspingIntervaldefault is 25000 ms
Events:
connectionfunction(socket:#Socket) emit client connected
Socket(opts:Object)
Properties:
idwebsoket idcookies#Object, key value array
Functions:
sendfunction (data: #Object) sends data to socket clientinfunction (room: #String) return two functions to send data in room to other sockets: send and broadcastenterRoomfunction (room: #String)leaveRoomfunction (room: #String)leaveAllfunction () leave all roomsclosefunction (reason #String) disconnect socket
Events:
messagefunction (data) incoming message to socketdisconnectfunction (reason)
wss.on('connection', function(socket){
socket.enterRoom('test room');
socket.in('test room').send('Hi all!');
socket.leaveRoom('test room');
});0.3.14
8 years ago
0.3.13
10 years ago
0.3.12
10 years ago
0.3.11
10 years ago
0.3.10
11 years ago
0.3.9
11 years ago
0.3.8
11 years ago
0.3.7
11 years ago
0.3.6
11 years ago
0.3.5
11 years ago
0.3.4
11 years ago
0.3.3
11 years ago
0.3.2
11 years ago
0.3.1
11 years ago
0.3.0
11 years ago
0.2.0
11 years ago
0.1.1
11 years ago
0.1.0
11 years ago