Now with Partition Management
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    simplesocket-serverpublic

    simplesocket-server

    Description

    Adds Room / Namespace layer on top of WebSocket-Node in node.js. This library was created because I like socket.io API but I ran into multiple issues when using it in production environment.

    simplesocket-server together with simplesocket-client can interact with each other in a similar fashion to socket.io client and server.

    Installation

    npm install simplesocket-server

    Usage

    // supports any http server including express 
    var server = require("simplesocket-server").listen(httpServer);
     
    server.on('connect', function (socket) {
      // trigger 'news' event  
      socket.trigger('news', { hello: 'world' });
      
      socket.on('eventName', function (data) {
        console.log(data);
      });
      
      // join specific room 
      socket.join('roomName');
      
      // send data to all clients in given room 
      server.in('roomName').trigger('eventName', { 'key': 'value' });
    });
     

    License:

    The MIT License
    

    Keywords

    none

    install

    npm i simplesocket-server

    Downloadsweekly downloads

    0

    version

    0.0.1

    license

    none

    last publish

    collaborators

    • avatar