Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Socket.io store using mongodb.
branch: master
Failed to load latest commit information.
bench Initial commit
lib Fix arguments being passed to mubsub.
test Initial commit
README.md Fix arguments being passed to mubsub.
index.js Initial commit
package.json updated version number.

README.md

Socket.io store implementation using mongodb.

This is a socket.io store using mongo based on the socket.io-mongo module by Oleg Slobodskoi. I updated the store to support the most recent versions of socket.io, mongo, and mubsub.

Version 0.9.2 works with mubsub version 1.02. Note that the capped collection storage format has changed from that in versions <= 0.9.1.

Install

npm install mong.socket.io

Usage example

var socketio = require('socket.io'),
    express = require('express'),
    MongoStore = require('mong.socket.io'),
    app = express.createServer(),
    io = io.listen(app);

app.listen(8000);

io.configure(function() {
    var store = new MongoStore({url: 'mongodb://localhost:27017/yourdb'});
    store.on('error', console.error);
    io.set('store', store);
});

io.sockets.on('connection', function (socket) {
    socket.emit('news', { hello: 'world' });
    socket.on('my other event', function (data) {
        console.log(data);
    });
});

Options

// Default options
{
   collectionPrefix: 'socket.io.' // collection name is prefix + name
  ,streamCollection: 'stream'     // capped collection name
  ,storageCollection: 'storage'   // collection name used for key/value storage
  ,nodeId: null // id that uniquely identifies this node
  ,size: 100000 // max size in bytes for capped collection
  ,num: null  // max number of documents inside of capped collection
  ,url: null  // db url e.g. "mongodb://localhost:27017/yourdb"
  ,host: 'localhost'  // optionally you can pass everything separately
  ,port: 27017
  ,db: 'mongsocketio'
};

new MongoStore(options);

Run tests

These tests are based on the same suite from socket.io-mongo and written using mocha.

Something went wrong with that request. Please try again.