Skip to content

Instantly share code, notes, and snippets.

@ir4y
Created December 14, 2013 13:26
Show Gist options
  • Select an option

  • Save ir4y/7959102 to your computer and use it in GitHub Desktop.

Select an option

Save ir4y/7959102 to your computer and use it in GitHub Desktop.
connection.openSignalingChannel = function(config) {
var websocket = new WebSocket('ws://localhost:8008/voice/my_group');
websocket.channel = config.channel || this.channel;
websocket.onopen = function () {
websocket.push(JSON.stringify({
open: true,
channel: websocket.channel
}));
if (config.callback) config.callback(websocket);
};
websocket.onmessage = function (event) {
config.onmessage(JSON.parse(event.data));
};
websocket.push = websocket.send;
websocket.send = function (data) {
websocket.push(JSON.stringify({
data: data,
channel: websocket.channel
}));
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment