Skip to content

Commit

Permalink
WebSocket over Node.js — added
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Jun 5, 2013
1 parent 83cd060 commit 6239acd
Show file tree
Hide file tree
Showing 396 changed files with 32,205 additions and 175 deletions.
162 changes: 100 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,42 @@ These demos/experiments are entirely client-side; i.e. no server installation ne

----

#### Browser Support
### Libraries

[WebRTC Experiments](https://webrtc-experiment.appspot.com) works fine on following web-browsers:

| Browser | Support |
| ------------- |-------------|
| Firefox | [Stable](http://www.mozilla.org/en-US/firefox/new/) / [Aurora](http://www.mozilla.org/en-US/firefox/aurora/) / [Nightly](http://nightly.mozilla.org/) |
| Google Chrome | [Stable](https://www.google.com/intl/en_uk/chrome/browser/) / [Canary](https://www.google.com/intl/en/chrome/browser/canary.html) / [Beta](https://www.google.com/intl/en/chrome/browser/beta.html) / [Dev](https://www.google.com/intl/en/chrome/browser/index.html?extra=devchannel#eula) |
| Internet Explorer / IE | [Chrome Frame](http://www.google.com/chromeframe) |
| Android | [Chrome Beta](https://play.google.com/store/apps/details?id=com.chrome.beta&hl=en) |
1. [RTCMultiConnection.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCMultiConnection) — A JavaScript library for streams renegotiation and sharing; multi-session establishment and much more.
2. [DataChannel.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/DataChannel) — A JavaScript library for data/file/text sharing!
3. [RecordRTC.js](https://webrtc-experiment.appspot.com/RecordRTC/) — A library to record audio/video streams / [Demo](https://webrtc-experiment.appspot.com/RecordRTC/)
4. [RTCall.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCall) — A library for Browser-to-Browser audio-only calling / [Demo](https://webrtc-experiment.appspot.com/RTCall/)

----

### Simplest Libraries Ever!
#### WebRTC Signaling Gateways

1. [DataChannel.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/DataChannel) — A JavaScript library for data/file/text sharing!
2. [RTCMultiConnection.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCMultiConnection) — A JavaScript library for streams renegotiation and sharing; multi-session establishment and much more.
3. [RecordRTC.js](https://webrtc-experiment.appspot.com/RecordRTC/) — A library to record audio/video streams
4. [RTCall.js](https://webrtc-experiment.appspot.com/RTCall/) — A library for Browser-to-Browser audio-only calling
Following signaling gateways can work with each and every [WebRTC Experiment](https://webrtc-experiment.appspot.com/)!

Scroll to bottom of the page to see how to use these four unique libraries!
1. [WebSocket over Node.js](https://github.com/muaz-khan/WebRTC-Experiment/blob/master/websocket-over-nodejs)[Demo](http://websocket-over-nodejs.jit.su/)
2. [Socket.io over Node.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs)[Demo](http://webrtc-signaling.jit.su/)

----

1. [Pre-recorded media streaming](https://webrtc-experiment.appspot.com/Pre-recorded-Media-Streaming/) — Most demanded and useful feature!
2. [Socket.io over Node.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) — Copy/Paste/Deploy and you're done!
1. [RecordRTC: WebRTC audio/video recording](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RecordRTC) / [Demo](https://webrtc-experiment.appspot.com/RecordRTC/)
2. [Pre-recorded media streaming](https://webrtc-experiment.appspot.com/Pre-recorded-Media-Streaming/)
3. [WebRTC one-way video broadcasting](https://webrtc-experiment.appspot.com/webrtc-broadcasting/)

----

#### Many-to-Many style of WebRTC Experiments

1. [Group video sharing / video-conferencing](https://webrtc-experiment.appspot.com/video-conferencing/)
2. [Group file sharing](https://webrtc-experiment.appspot.com/file-hangout/)
3. [Group text chat](https://webrtc-experiment.appspot.com/chat-hangout/)

----

### One-way video broadcasting

1. [WebRTC one-way video broadcasting](https://webrtc-experiment.appspot.com/webrtc-broadcasting/)

----

#### One-to-Many style of WebRTC Experiments

1. [Video broadcasting](https://webrtc-experiment.appspot.com/broadcast/)
2. [Audio broadcasting](https://webrtc-experiment.appspot.com/audio-broadcast/)

----

#### One-to-One style of WebRTC Experiments
#### [Screen sharing](https://webrtc-experiment.appspot.com/#screen-sharing)

1. [One-to-one WebRTC video chat using WebSocket](https://webrtc-experiment.appspot.com/websocket/)
2. [One-to-one WebRTC video chat using socket.io](https://webrtc-experiment.appspot.com/socket.io/)
1. [Plugin free screen sharing](https://webrtc-experiment.appspot.com/Pluginfree-Screen-Sharing/)
2. [Screen sharing](https://webrtc-experiment.appspot.com/screen-broadcast/)

----

#### [Screen sharing](https://webrtc-experiment.appspot.com/#screen-sharing)
#### Many-to-Many style of WebRTC Experiments

1. [Plugin free screen sharing](https://webrtc-experiment.appspot.com/Pluginfree-Screen-Sharing/)
2. [Screen sharing](https://webrtc-experiment.appspot.com/screen-broadcast/)
1. [Group video sharing / video-conferencing](https://webrtc-experiment.appspot.com/video-conferencing/)
2. [Group file sharing](https://webrtc-experiment.appspot.com/file-hangout/)
3. [Group text chat](https://webrtc-experiment.appspot.com/chat-hangout/)

----

Expand All @@ -81,18 +56,6 @@ Scroll to bottom of the page to see how to use these four unique libraries!

----

#### WebRTC Audio/Video Recording

[RecordRTC: WebRTC audio/video recording](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RecordRTC) / [Demo](https://webrtc-experiment.appspot.com/RecordRTC/)

----

#### Pre-recorded media streaming

[Pre-recorded media streaming](https://webrtc-experiment.appspot.com/Pre-recorded-Media-Streaming/)

----

#### Demos using [DataChannel.js](https://webrtc-experiment.appspot.com/DataChannel.js)

1. [DataChannel basic demo](https://webrtc-experiment.appspot.com/DataChannel/)
Expand All @@ -117,6 +80,21 @@ Scroll to bottom of the page to see how to use these four unique libraries!
13. [Customizing Bandwidth](https://webrtc-experiment.appspot.com/RTCMultiConnection/bandwidth/)
14. [RTCMultiConnection-v1.3 testing demo](https://webrtc-experiment.appspot.com/RTCMultiConnection-v1.3/)


----

#### One-to-Many style of WebRTC Experiments

1. [Video broadcasting](https://webrtc-experiment.appspot.com/broadcast/)
2. [Audio broadcasting](https://webrtc-experiment.appspot.com/audio-broadcast/)

----

#### One-to-One style of WebRTC Experiments

1. [One-to-one WebRTC video chat using WebSocket](https://webrtc-experiment.appspot.com/websocket/)
2. [One-to-one WebRTC video chat using socket.io](https://webrtc-experiment.appspot.com/socket.io/)

----

| in-Page / One-Page / Client Side |
Expand Down Expand Up @@ -154,9 +132,16 @@ Scroll to bottom of the page to see how to use these four unique libraries!

```javascript
var channel = new DataChannel('channel-name');

channel.onopen = function(e) {};
channel.onmessage = function(e) {};

// share with all participants
channel.send(file || data || 'text');

// Direct messages using user-ids
channel.userid = 'muazkh';
channel.channels['muazkh'].send(file || data || 'text');
```

----
Expand All @@ -169,6 +154,14 @@ channel.send(file || data || 'text');

```javascript
var connection = new RTCMultiConnection();
connection.session = {
audio: true,
video: true
};
connection.bandwidth = {
audio: 50,
video: 256
};
connection.onstream = function (e) {
if (e.type === 'local') mainVideo.src = e.blobURL;
if (e.type === 'remote') document.body.appendChild(e.mediaElement);
Expand All @@ -178,10 +171,7 @@ connection.onstream = function (e) {
connection.connect('session-id');

// to create/open a new session
// it should be called "only-once" by the session-initiator
[button-init-session].onclick = function() {
connection.open('session-id');
};
connection.open('session-id');
```

----
Expand All @@ -204,7 +194,40 @@ call.oncustomer = function(customer) {

----

#### Use [your own](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) socket.io implementation!
#### Use [WebSocket over Node.js](https://github.com/muaz-khan/WebRTC-Experiment/blob/master/websocket-over-nodejs) for signaling

In `ui.js` files you can find `openSocket` method; or in all libraries; you can find `openSignalingChannel` method.

```javascript
var SIGNALING_SERVER = 'ws://' + document.domain + ':8888/';
openSignalingChannel: function(config) {
config.channel = config.channel || 'default-channel';
var websocket = new WebSocket(SIGNALING_SERVER);
websocket.channel = config.channel;
websocket.onopen = function() {
websocket.push(JSON.stringify({
open: true,
channel: config.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: config.channel
}));
};
}
```

----

#### Use [Socket.io over Node.js](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs) for signaling!

```javascript
// openSignalingChannel or openSocket!
Expand Down Expand Up @@ -238,7 +261,9 @@ openSignalingChannel: function(config) {

For a ready-made socket.io over node.js implementation; [visit this link](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs).

#### Use `firebase` for testing purpose!
----

#### Use `firebase` for signaling!

Remember, You must link [firebase.js](https://cdn.firebase.com/v0/firebase.js) file before using below code:

Expand Down Expand Up @@ -304,6 +329,19 @@ recorder.stopAudio(function(recordedFileURL) {

----

#### Browser Support

[WebRTC Experiments](https://webrtc-experiment.appspot.com) works fine on following web-browsers:

| Browser | Support |
| ------------- |-------------|
| Firefox | [Stable](http://www.mozilla.org/en-US/firefox/new/) / [Aurora](http://www.mozilla.org/en-US/firefox/aurora/) / [Nightly](http://nightly.mozilla.org/) |
| Google Chrome | [Stable](https://www.google.com/intl/en_uk/chrome/browser/) / [Canary](https://www.google.com/intl/en/chrome/browser/canary.html) / [Beta](https://www.google.com/intl/en/chrome/browser/beta.html) / [Dev](https://www.google.com/intl/en/chrome/browser/index.html?extra=devchannel#eula) |
| Internet Explorer / IE | [Chrome Frame](http://www.google.com/chromeframe) |
| Android | [Chrome Beta](https://play.google.com/store/apps/details?id=com.chrome.beta&hl=en) |

----

#### License

[WebRTC Experiments](https://webrtc-experiment.appspot.com/) are released under [MIT licence](https://webrtc-experiment.appspot.com/licence/) . Copyright (c) 2013 [Muaz Khan](https://plus.google.com/100325991024054712503).
1 change: 0 additions & 1 deletion RTCMultiConnection/RTCMultiConnection-v1.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,6 @@
});
});
} else {
log('no way, it is too bad!');
// otherwise; suggest other user to play role of renegotiator
socket.send({
userid: self.userid,
Expand Down
24 changes: 6 additions & 18 deletions socket.io/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
<article>
<a href="https://webrtc-experiment.appspot.com/" style="border-bottom: 1px solid #2844FA; font-size: 1.2em; position: absolute; text-decoration: none;right:0;top:0;">↑ WEBRTC EXPERIMENTS</a>

<h1>Using socket.io for signaling</h1>
<h1>Using socket.io for signaling / <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socket.io" target="_blank">Source Code on Github</a></h1>
<p>
<span>Copyright © 2013</span>
<a href="https://github.com/muaz-khan" target="_blank">Muaz Khan</a><span>&lt;</span><a href="http://twitter.com/muazkh" target="_blank">@muazkh</a><span>&gt;.</span>
Expand Down Expand Up @@ -212,27 +212,15 @@ <h2>
<script src="https://webrtc-experiment.appspot.com/RTCPeerConnection-v1.5.js"></script>
<script src="https://webrtc-experiment.appspot.com/socket.io/rtclib.js"> </script>
<script src="https://webrtc-experiment.appspot.com/socket.io/ui.js"></script>

<br />
<br />

<h2 style="float:right;"><a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socket.io" target="_blank">Source Code on Github</a></h2>
<p>WebRTC one-to-one video sharing experiment where socket.io is used for signaling.</p>
</article>
<article>
<h2>Use <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs" target="_blank">Socket.io over Node.js</a> for signaling! / <a href="http://webrtc-signaling.jit.su/" target="_blank">Demo</a></h2>

<br />
<br />

WebRTC one-to-one video sharing experiment where socket.io is used for signaling.
<br />
<br />

<h2>
Interested to write your own <span style="color:red;">socket.io over node.js</span> application for signaling? <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs" target="_blank" title="Copy, paste and you're done!">Try this!</a>
</h2>
<br />
<br />

You can use <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCMultiConnection" target="_blank">RTCMultiConnection.js</a> for audio/video/screen conferencing/broadcasting, multi-sessions on the same page, text chat and file sharing!

You can use <a href="https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCMultiConnection" target="_blank">RTCMultiConnection.js</a> library for everything!

<br /><br />
<table style="width: 100%;">
Expand Down
3 changes: 2 additions & 1 deletion socket.io/ui.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* MIT License: https://webrtc-experiment.appspot.com/licence/ */
// MIT License: https://webrtc-experiment.appspot.com/licence/
// Use Socket.io over Node.js for signaling: https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs

var config = {
openSocket: function (config) {
Expand Down
Loading

0 comments on commit 6239acd

Please sign in to comment.