Giter VIP home page Giter VIP logo

device's Introduction

device

Higher-level API built on matthewmueller/io for separating out socket logic and identifying clients, so messages can be passed between them.

Installation

$ component install matthewmueller/device

Example

var device = require('device')('http://socketserver.com');

var batter = device('batter').type('mobile');
var pitcher = device('pitcher').type('mobile');
var field = device('field').type('desktop');

batter.ready(function() {
  batter.on('throw', hitHomerun);
});

pitcher.ready(function() {
  pitcher.emit('throw');
});

field.ready(fn);

API

require('device')(url)

Initialize the devices with the given url. This is the url that gets passed into matthewmueller/io and ultimately into learnboost/engine.io.

device(name, type)

Initialize a device with a given name. This name should uniquely identify the device from the rest of the devices in the room. type can be "mobile", "desktop", or "tablet";

.ready(fn)

Initializes the socket and calls fn when done. This library uses socket pooling in order for each connected client to call at most one ready function.

Ready can be called multiple times with multiple functions fn.

iphone.ready(doThis);
iphone.ready(doThat);

Socket Server

There are some assumptions made about the configuration of the socket server. Head over to matthewmueller/ws.mat.io to see the server-side component.

Test

You'll need to edit the test.html to point to your socket server's address. Then do:

make
serve &
open http://localhost:3000

License

MIT

device's People

Contributors

matthewmueller avatar

Stargazers

Wu Dong 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.