0.1.2 • Published 7 years ago

appeerjs-server v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

AppeerJS Server

A simple signaling server built for appeerjs clients using Socket.io.

Getting Started

  1. Go to your project directory using your command line tool then install the project using npm.

    npm install appeerjs-server
  2. Require appeer.js to your main server script.

    var appeer = require('appeerjs-server');
  3. Setup the Socket.io and then instantiate the AppeerServer inside the connection event. Let's say the file name is server.js.

    var app = express();
    var fs = require('fs');
    
    // Add your ssl certificates
    var sslConf = {
      key: fs.readFileSync('server.key'),
      cert: fs.readFileSync('server.crt')
    };
    
    // Create an https server instance to listen to request
    var server = require('https').createServer(sslConf, app);
    var io = require('socket.io').listen(server);
    
    // Middleware to get the custom id of the connecting user
    io.use(appeer.getCustomIdMiddleware);
    io.on('connection', function (socket) {
        console.log('A user has connected with socket id', socket.id);
        appeer.initListeners(io, socket, {
          debug: true // Set to true to show console logs and errors, defaults to false
        });
    });
  4. Run the server, and you're good to go.

    node server.js

Inspirations and Motivations

Credits

License

This project is licensed under the MIT License - see the LICENSE file for details

TODO

  • Unit tests
0.1.2

7 years ago

0.0.2

7 years ago

0.0.1

8 years ago