Skip to content

javascript remote evented driven with engine.io built on top of findhit-evented

License

Notifications You must be signed in to change notification settings

findhit/findhit-remote-evented

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Remote Evented test-badge

javascript remote evented driven with engine.io built on top of findhit-evented

Instalation

	npm install findhit-remote-evented --save

Usage

// We need an already stablished engine.io socket connection!
// so i will suppose that you already have one
var socket;

var RemoteEvented = require('findhit-remote-evented');

var Call = RemoteEvented.extend({

  // you can specify methods as `findhit-class`
  initialize: function ( my, cool, params ) {
    // ...
  },

  ring: function () {
    // ...
    this.fire('ring');
  },

  // You can bind events directly from extend as `findhit-evented`
  $on: {
    ring: function () {
      // ...
    },
  },

  // And now from remote party.
  $onRemote: {

    answer: function ( e ) {
      this.stopRing();
    },

  },

});

// We could extend it to a new class and setup it with a specific socket.
// In this case we will setup directly on current class `.setup( namespace, socket )`
Call.setup( 'VideoCall', socket );

// When you create an instance, another party will create one also
var bruno = new Call();

// You can bind or fire events as `findhit-evented`
bruno.fire('ring');
bruno.on('ring ring-stopped', function () {
  // ...
});
bruno.once('answered', function () {
  // ...
});

// And now from remote party
bruno.fireOnRemote( 'ring' );
bruno.onRemote( 'ring ring-stopped', function () {
  // ...
});
bruno.onceRemote('answered', function () {
  // ...
});

// Thats it, take a look at `test` and `example` folders for more cases.
// You don't see them? Pull Request them :)

About

javascript remote evented driven with engine.io built on top of findhit-evented

Resources

License

Stars

Watchers

Forks

Packages

No packages published