Git Product home page Git Product logo

roomsjs's Introduction

roomsjs - streaming live data built to support different transporters

Build Status NPM version

roomsjs logo

A Javascript Node.JS module, provides a way to send and receive messages and switch different transporters for creating rooms and streaming data between users, streaming data from a database and even stream from a 3rd party CDN. roomsjs, roomsdb and roomsjs-client together combine a powerful light-weight backend/front-end libraries built to stream live data and solve same problems related to real-time communications.

Node.js technology relatively young and memory leaks were found in socket.io and issues around engine.io's Websocket transporter on certain nodejs version.

The API was built to allow you to just 'switch' and use any transporter and create your own implementation. Module also have additional feature to help managing rooms easily.

The idea is to give a simple API and allowing using different transporters and modify the client implementation instead of having to do an 'open heart surgery' when you are already committed to one transporter API or another. It's recommended to use engine.io since it's the high level API of socket.io, however there are cases where you want to have the socket.io bloated code for certain functionality. rooms.js is a lower level API, just like socket.io, however it's lighter weight and doesn't have the sugar and all the bell and whistle of socket.io, so it's here for you to use.

roomsjs has features such as:

1. Connect to a room
2. Register a user
2. Request number of users
3. Private message
4. Video
5. Create multiple rooms
6. Store states.
7. Subscribe to data VO.
8. AMS/FMS Flash Webcam fallback
9. HTML5 Webcam (still in development)
10. Database connector (such as mysql, mongodb).
11. Switch different transporters: currently supporting `socket.io`, `engine.io` and `SockJS`.
12. Angularjs implementation

Installation

Install with the Node.JS package manager npm:

  $ npm install roomsjs
  $ npm install rooms.db

Download the front-end roomjs min file: https://raw.github.com/eladelrom/roomsjs-client/master/client/dist/libs/rooms.min.js

Or install with bower:

bower install roomsjs-client

Quick getting started example

create a project and install packages:

cd ~/dev mkdir rooms && cd $_ npm install roomsjs rooms.db express

Server code to create the rooms, services and connect to database and/or 3rd party APIs for streaming;

'use strict';

var os = require('os'),
  rooms = require('roomsjs'),
  roomdb = require('rooms.db'),
  port = (process.env.PORT || 8081);

// create express server if needed
var express = require('express'),
  app = express().use(express.static(__dirname + '/client'));

// engine.io, socket.io
var server = require('http').createServer(app).listen(port, function () {
  console.log('Listening on http://' + os.hostname() + ':' + port);
});
// OR for sockjs
// var server = require('http').createServer(app).listen(port, '0.0.0.0');

// services
roomdb.setServices('services_sample/', app); // pass the app to get rest services or null

// connect to different database/s if needed
// Mysql:
// roomdb.connectToDatabase('mysql', 'localhost', {user: 'root', password: ''});
// MongoDB
roomdb.connectToDatabase('mongodb', 'mongodb://localhost/test', {});

// set rooms
rooms = new rooms({
  isdebug : true,
  transporter : {
    type: 'engine.io', /* options: engine.io|socket.io|sockjs */
    server : server
  },
  roomdb : roomdb /* or null if db not needed */
});

Rooms.db services examples:

services_example/
  |- examples/
  |  |  |- cloudsearch.js [Cloud Search data source example]
  |  |  |- getitems.js [mySQL data source example]
  |  |  |- getnames.js [Static data example]
  |  |  |- insertchatmessage.js [Mongodb example]

Front-end example of getting the number of visitors and data from external sources:

Examples of front-end implementation of rooms includes connecting to engine.io, socket.io and sockjs see here:

client/
  |- examples/
  |  |  |- engineio
  |  |  |- socketio
  |  |  |- sockjs
  |  |  |- angular

Docs:

Below is a ten thousand foot diagram that shows how the different pieces of the platform are coming together using socketio.

backend diagram

See more information here about init concept read here: http://effectiveidea.com/_posts/roomsjs

LICENSE

BSD license.

roomsjs's People

Contributors

elieladelrom avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.