var http = require("http"); // http server core module
var express = require("express"); // web framework external module
var io = require("socket.io"); // web socket external module var easyrtc = require("easyrtc"); // EasyRTC external module
// Setup and configure Express http server. Expect a subfolder called "static" to be the web root.
var httpApp = express();
httpApp.configure(function() {
httpApp.use(express.static(__dirname + "/static/"));
});
var webServer = http.createServer(httpApp).listen(80);
var socketServer = io.listen(webServer);
// Start EasyRTC server with options to change the log level and add dates to the log.
var easyrtcServer = easyrtc.listen(
httpApp,
socketServer,
{logLevel:"debug", logDateEnable:true},
function(err, rtc) {
// Creates a new application called easyrtc.instantMessaging with locked down rooms.
rtc.createApp(
"easyrtc.instantMessaging",
{
"roomAutoCreateEnable":false,
"roomDefaultEnable":false
},
myEasyrtcApp
);
}
);
// Callback listener for the EasyRTC application "easyrtc.instantMessaging"
var myEasyrtcApp = function(err, appObj) {
appObj.createRoom("redroom",null,function(err, roomObj){});
appObj.createRoom("blueroom",null,function(err, roomObj){});
appObj.createRoom("greenroom",null,function(err, roomObj){});
};