Skip to content

The core processing logic of rtc-switchboard without assuming any network transport

Notifications You must be signed in to change notification settings

rtc-io/rtc-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rtc-switch

This is a processor layer for the rtc-switchboard that is capable of talking with an rtc-signaller up to and including version 5.

NPM

unstable Build Status bitHound Score

Example Usage

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');
});

License(s)

Apache 2.0

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.

About

The core processing logic of rtc-switchboard without assuming any network transport

Resources

Stars

Watchers

Forks

Packages

No packages published