Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

hungluu/smokeweed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  1. Install
npm install --save smokeweed
  1. Start websocket server
var smokeweed = require('smokeweed');
var server = smokeweed();
// or everyone has a unique name :)
var server = smokeweed({
    client : smokeweed.namedClient
});
  1. 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');
});

About

An implementation of ws for ez life - ez websocketing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published