README
SmokeWeed
An implementation of ws for ez life - ez websocketing. A holy library for you to write websocket application in minutes while having time to smoke weed :)
Just kidding. This is a library for my personal usage. If you wanna use it, you can follow below instruction:
- Install
npm install --save smokeweed
- Start websocket server
var smokeweed = require('smokeweed');
var server = smokeweed();
// or everyone has a unique name :)
var server = smokeweed({
client : smokeweed.namedClient
});
- Bind events
server.on('connect', function(client){
// close, pong, ...
client.on('close', function(){});
// send a message to current client
client.write('title', 'data');
// listen for a message
client.read('title', function(data){});
// write message to another user with his name
client.write('title', 'data', 'John');
// broadcasting
client.broadcast('title', 'data');
});