node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

kotomono

kotomono

A customizable websocket library

How does it work?

Namespaces

The idea behind kotomono is to provide the utilities to build a flexible socket server. Kotomono allows you to set up namespaces.

A namespace can be any word (i.e. 'global' or 'push-notifications'). You can define events under the namespace which can manage all the sockets subscribed to that namespace.

var namespaces = {
  'global': {
    'join-ns': function(s, ..) {
    },
    'close': function (s, ..) {
      logger.info('A user disconnected.');
    }
  },
  'channel': {
    'user-count': function (s, ..) {
      logger.info('The event user-count was triggered.');
    },
    'message': function (s, ..) {
      socket.send(event);
    }
  },
  'push-notifications': {
    // ..
  }
}
 
module.exports = namespaces;

Customization

Kotomono provides a way to pass any customizable object to namespace events.