Giter Site home page Giter Site logo

rtc's Introduction

<<<<<<< HEAD

socket.io over node.js for webrtc-signaling!

=

Install via npm

npm install socketio-over-nodejs

and run the signaler.js nodejs file:

node ./node_modules/socketio-over-nodejs/signaler.js

Now you can test: http://localhost:8888/

=

Install on Linux/Ubuntu/CentOS/Debian/Mac etc.

# create a directory
mkdir socketio-over-nodejs

# open directory
cd socketio-over-nodejs

# get package
wget http://cdn.webrtc-experiment.com/packages/socketio-over-nodejs.tar

# extract package
tar -xf socketio-over-nodejs.tar

# run node.js server
node signaler.js

Now, you can open port 8888 on your ip address/domain; or otherwise on localhost: http://localhost:8888/

=

It is using port 8888; you can edit this port using following commands:

vi signaler.js

# now edit port 12034
# and save changes & quit

# press "insert" key; then press "Esc" key and the type
:wq

:wq command saves changes in the file and exits editing mode. If you don't want to save changes; simply type:

# if you don't want to save changes however want to exit editing mode
:q

Common Error: Error: listen EADDRINUSE. It means that same port is used by another application. You can close all existing processes running on same port:

// list all active processes running on same port
fuser -v 8888/tcp

// kill all processes running on port "8888"
fuser -vk 8888/tcp

// list again to verify closing ports
fuser -v 8888/tcp

You can delete "directory" and re-install:

rm -rf socketio-over-nodejs
mkdir socketio-over-nodejs

# and following above steps to "wget" and "tar" then "node" to run!

=

  1. https://www.webrtc-experiment.com/docs/WebRTC-Signaling-Concepts.html
  2. http://www.RTCMultiConnection.org/FAQ/
  3. http://www.RTCMultiConnection.org/docs/sessionid/
  4. http://www.RTCMultiConnection.org/docs/channel-id/

=

Otherwise, follow these steps:

  1. Download and extract ZIP file of this repository then copy folder-location of thesignaler.js file
  2. Open Node.js command prompt window
  3. Type command cd folder-location where folder-location can be C:\socketio-over-nodejs
  4. Type npm install express or download ZIP
  5. Type npm install socket.io or download ZIP
  6. Type node signaler to run the node.js server

Then open http://localhost:8888/.

=

If you want to deploy your application

  1. Create an account at nodejitsu
  2. Use same Node.js command prompt window
  3. Type jitsu deploy

and you're done!

Remember: jitsu deploy command will deploy the entire directory containing all all files including node_modules (i.e. dependencies).

=

How to use?

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

// http://socketio-over-nodejs.hp.af.cm/
// http://socketio-over-nodejs.jit.su:80/
// http://webrtc-signaling.jit.su:80/

var SIGNALING_SERVER = 'https://webrtc-signaling.nodejitsu.com/';
connection.openSignalingChannel = function(config) {   
   var channel = config.channel || this.channel || 'default-namespace';
   var sender = Math.round(Math.random() * 9999999999) + 9999999999;
   
   io.connect(SIGNALING_SERVER).emit('new-channel', {
      channel: channel,
      sender : sender
   });
   
   var socket = io.connect(SIGNALING_SERVER + channel);
   socket.channel = channel;
   
   socket.on('connect', function () {
      if (config.callback) config.callback(socket);
   });
   
   socket.send = function (message) {
        socket.emit('message', {
            sender: sender,
            data  : message
        });
    };
   
   socket.on('message', config.onmessage);
};

io.connect(URL).emit('new-channel') starts a new namespace that is used privately or publicly to transmit/exchange appropriate stuff e.g. room-details, participation-requests, SDP, ICE, etc.

=

Presence Detection

You can detect presence of a room like this:

// http://socketio-over-nodejs.hp.af.cm/
// http://socketio-over-nodejs.jit.su:80/
// http://webrtc-signaling.jit.su:80/

var SIGNALING_SERVER = 'https://webrtc-signaling.nodejitsu.com/';
function testChannelPresence(channel) {
    var socket = io.connect(SIGNALING_SERVER);
    socket.on('presence', function (isChannelPresent) {
        console.log('is channel present', isChannelPresent);
        if (!isChannelPresent) startNewSession();
    });
    socket.emit('presence', channel);
}

// test whether default channel already created or not!
testChannelPresence('default-channel');

=

What is cd folder-location?

Using this command; you can open project's directory (i.e. folder).

=

What is node signaler?

This command runs node.js server via signaler.js file. That file handles socket.io relevant stuff.

=

What is jitsu deploy?

This command deploys the entire directory (i.e. project, including all node_modules dependencies) over nodejitsu servers. You will be able to access your deployed project using URL like this:

https://username.nodejitsu.com/

See the demo URL: https://webrtc-signaling.nodejitsu.com/

=

Note

Each experiment is using something like this:

var SIGNALING_SERVER = '/';

This is the URL of your site. By default it will be equal to http://localhost:8888/.

It is strongly recommended to use absolute URL including port number:

var SIGNALING_SERVER = 'http://domain.com:8888/';

=

Are you beginner or totally novice?

  1. To run socket.io on your computer; you need to download node.js software from nodejs.org.
  2. If you're using windows; in the Start Menus; you can type node in the search-box. Node.js command prompt will be listed on the top.
  3. You can use same command prompt to run any node.js file; also you can write nodejitsu commands in the same place e.g. jitsu deploy or jitsu login etc.
  4. Default port 8888 is used for this experiment. You can manually open this URL: http://localhost:8888/

=

Signaling Concepts

Interested to understand WebRTC Signaling Concepts? Read this document.

=

SSL/TLS/HTTPS/Socket.io/Node.js ??

muaz-khan/WebRTC-Experiment#62

=

License

Socket.io over Node.js is released under MIT licence . Copyright (c) Muaz Khan.

Rtc

c1875f568e50206cfaacf8907cdf403a905526f8

rtc's People

Contributors

krunnal avatar prasadkonde avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.