A Node.JS module, provides an object oriented wrapper for socketio for creating rooms and streaming data between users, streaming data from a database and even 3rd party services.
roomsjs
based on Socket.IO, roomsdb
and roomsjs-fronend
combine together provides a powerful light-weight backend/front-end libraries built to stream live data, stream data from a database and even stream 3rd party APIs.
It 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 Webcam
9. HTML5 Webcam
10. Database connector (mysql)
Install with the Node.JS package manager npm:
$ npm install roomsjs
$ npm install rooms.db
Download the front-end min file: https://raw.github.com/EladElrom/roomsjs-fronend/master/public/js/libs/socketcontroller.min.js
Example of front-end implementation of socketcontroller
:
https://raw.github.com/EladElrom/roomsjs-fronend/master/public/js/autostartcontroller.js
Front-end dependencies: jquery.js
, socket.io.js
Download complete front-end example from here see public
folder:
https://github.com/EladElrom/roomsjs-fronend
Back-end code to create the rooms services and connect to database and/or 3rd party APIs for streaming;
var express = require('express'),
app = express(),
os = require('os'),
http = require('http'),
server = http.createServer(app),
rooms = require('roomsjs'),
roomdb = require('rooms.db'),
port = (process.env.PORT || 8081);
app.use(express.static(__dirname + '/public'));
server.listen(port, function () {
console.log('Listening on http://' + os.hostname() + ':' + port);
});
// services
roomdb.setServices('roomsdb_services_sample/');
// connect database
roomdb.connectToDatabase('mysql', 'localhost', 'root', '');
// set rooms
rooms = new rooms({
server : server,
isdebug : true,
socketio : null,
roomdb : roomdb /* or null if no db needed */
});
Front-end example of getting the number of visitors:
<html>
<head>
<title>Room controller</title>
<script type="text/javascript" src="js/libs/jquery.min.js"></script>
<script type="text/javascript" src="js/libs/jquery-ui.js"></script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/js/libs/socketcontroller.min.js"></script>
<script type="text/javascript" src="/js/autostartcontroller.js"></script>
<body>
<button id="getResultsButton">Get results</button>
<div id="visitors" />
</body>
</html>
Example of streaming a pod consists of live camera feeds and text comment feed between different users on a page and dragging the pods;
<html>
<head>
<title>Room controller</title>
<script type="text/javascript" src="js/libs/jquery.min.js"></script>
<script type="text/javascript" src="js/libs/jquery-ui.js"></script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/js/libs/socketcontroller.min.js"></script>
<script type="text/javascript" src="/js/controller.js"></script>
<script type="text/javascript" src="/js/model/vo/clientvo.js"></script>
<script type="text/javascript" src="/js/libs/swfobject.js"></script>
<body>
<div class="well" style="float: right; width: 300px; height: 300px; border: 1px solid #999;">
Click to start/stop dragging
<button id="grabAllPodsButton">Grab all pods</button>
</div>
<div id="visitors" />
</body>
</html>
Below is a ten thousand foot diagram that shows how the different pieces of the platform are coming together.
See more information here: http://effectiveidea.com/_posts/roomsjs
BSD license.