EasyRTC Documentation

Documentation

EasyRTC Server: Configuration

Configuration levels - Server versus Application versus Room

EasyRTC allows management of configuration options at the server, application and room level. This will allow different rooms in the same application, or different applications in the same server to run with customized options.

Setting Server Options

Options can be set prior, during, or after the easyrtc.listen() function has been run.

Seperate - easyrtc.setOption(optionName, optionValue)

Within Listen() - easyrtc.listen(httpApp, socketServer, options, listenCallback)

Afterwards with resulting EasyRTC interface function - ei.setOption(optionName, optionValue)

note: Not all options will have an effect if changed after the server has started.

Setting Server Options Example

The following server.js code snippet includes three ways of setting EasyRTC options.

// Load required modules
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.use(express.static(__dirname + "/static/"));

// Start Express http server on port 8080
var webServer = http.createServer(httpApp).listen(8080);

// Start Socket.io so it attaches itself to Express server
var socketServer = io.listen(webServer);

// Configure EasyRTC to load demos from /easyrtcdemos/
easyrtc.setOption("demosPublicFolder", "/easyrtcdemos");

// 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) {

            // After the server has started, we can still change the default room name
            rtc.setOption("roomDefaultName", "SectorZero");

            // Creates a new application called MyApp with a default room named "SectorOne".
            rtc.createApp(
                "easyrtc.instantMessaging",
                {"roomDefaultName":"SectorOne"},
                myEasyrtcApp
            );
        }
);

// Setting option for specific application
var myEasyrtcApp = function(err, appObj) {
    // All newly created rooms get a field called roomColor.
    // Note this does not affect the room "SectorOne" as it was created already.
    appObj.setOption("roomDefaultFieldObj",
         {"roomColor":{fieldValue:"orange", fieldOption:{isShared:true}}}
    );
};

Available Server Options

Application Options

Room Options

Connection Options

Session Options

API Hosting Options

Demo Options

Log options

Log options only apply if internal 'log' event is used

Miscellaneous Server Options

Regular expressions for validating names and other input

If You Run Into Problems

Please feel free to post on our discussion forum: