This is a processor layer for the rtc-switchboard that is capable of talking with an rtc-signaller up to and including version 5.
Plain old websockets:
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({ port: 8080 });
var board = require('rtc-switch')();
wss.on('connection', function connection(ws) {
var peer = board.connect();
ws.on('message', peer.process);
peer.on('data', function(data) {
if (ws.readyState === 1) {
console.log('OUT <== ' + data);
ws.emit("rtc-signal",data);
}
});
ws.on('close', peer.leave);
});
Using socket.io:
var http = require('http');
var server = http.createServer();
var io = require('socket.io')(server);
var board = require('rtc-switch')();
io.on('connection', function(socket){
var peer = board.connect();
socket.on('message', peer.process);
peer.on('data', function(data) {
socket.emit("rtc-signal",data);
});
});
server.listen(3000, function(){
console.log('listening on *:3000');
});
Copyright 2015 National ICT Australia Limited (NICTA)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.