-
Notifications
You must be signed in to change notification settings - Fork 147
Integrate inside nodejs applications
Muaz Khan edited this page Jan 12, 2019
·
4 revisions
This wiki explains how to require
and use inside your own nodejs codes.
require('rtcmulticonnection-server').addSocket(socket);
i.e.
const ioServer = require('socket.io');
const RTCMultiConnectionServer = require('rtcmulticonnection-server');
ioServer(httpApp).on('connection', function(socket) {
RTCMultiConnectionServer.addSocket(socket);
});
or:
var config = require('config.json');
const ioServer = require('socket.io');
const RTCMultiConnectionServer = require('rtcmulticonnection-server');
ioServer(httpApp).on('connection', function(socket) {
RTCMultiConnectionServer.addSocket(socket, { config: config });
});
or:
const ioServer = require('socket.io');
const RTCMultiConnectionServer = require('rtcmulticonnection-server');
ioServer(httpApp).on('connection', function(socket) {
RTCMultiConnectionServer.addSocket(socket, {
config: {
"socketURL": "/",
"dirPath": "",
"homePage": "/demos/index.html",
"socketMessageEvent": "RTCMultiConnection-Message",
"socketCustomEvent": "RTCMultiConnection-Custom-Message",
"port": "9001",
"enableLogs": "false",
"autoRebootServerOnFailure": "false",
"isUseHTTPs": "false",
"sslKey": "./fake-keys/privatekey.pem",
"sslCert": "./fake-keys/certificate.pem",
"sslCabundle": "",
"enableAdmin": "false",
"adminUserName": "username",
"adminPassword": "password"
},
logs: 'logs.json'
});
});
require('rtcmulticonnection-server') exposes following objects:
const RTCMultiConnectionServer = require('rtcmulticonnection-server');
const resolveURL = RTCMultiConnectionServer.resolveURL;
const BASH_COLORS_HELPER = RTCMultiConnectionServer.BASH_COLORS_HELPER;
const getValuesFromConfigJson = RTCMultiConnectionServer.getValuesFromConfigJson;
const getBashParameters = RTCMultiConnectionServer.getBashParameters;
const getJsonFile = RTCMultiConnectionServer.getJsonFile;
const pushLogs = RTCMultiConnectionServer.pushLogs;
const beforeHttpListen = RTCMultiConnectionServer.beforeHttpListen;
const afterHttpListen = RTCMultiConnectionServer.afterHttpListen;
const addSocket = RTCMultiConnectionServer.addSocket;
Note: Second parameter for RTCMultiConnectionServer.addSocket
is expected to be updated soon.