Coder Social home page Coder Social logo

skateboard's Introduction

skateboard

Quickly create a stream from the browser to the server with engine.io

Use

npm install skateboard

// server.js
var skateboard = require('skateboard');
skateboard({
  dir: __dirname + '/public',          // default (optional)
  port : 8080,                         // default (optional)
  transports: ['polling', 'websocket'] // default (optional)
  // requestHandler: function(req, res) {} -- fallback request handler
}, function(stream) {
  var start = Date.now();
  stream.write('ping');

  stream.on('data', function() {
    console.log('latency:', (Date.now() - start) + 'ms');
  });
});

skateboard([wshref [, fn]])

  • wshref - optional cross domain skateboard to connect to
  • fn - optional connection handler. first argument is a duplex stream
<!-- public/index.html -->
<html>
<head>
  <script type="text/javascript" src="skateboard.min.js"></script>
</head>
<body>

<script type="text/javascript">
  skateboard().on('data', function(d) {
    this.write(d);
  });

  // or
  // skateboard(function(stream) {
  //   stream.on('data', function(d) {
  //     stream.write(d);
  //   });
  // });
  //
</script>

</body>
</html>

client events

  • connection - emitted on the first connection
  • disconnection - emitted whenever the connection disconnects
  • reconnection - emitted whenever a new connection is established

License

MIT

skateboard's People

Contributors

tmpvar avatar rvagg avatar

Stargazers

Jet Street avatar memoyr / mdev / mindgspl avatar Kniffen avatar Nick Doiron avatar Jose Gonzalez avatar Daniel Sánchez avatar James Donaghue avatar Cyber Halunke avatar timelyportfolio avatar Fannar Snær Harðarson avatar Kevin Neff avatar Angus H. avatar Christian Gutierrez avatar ryan jarvinen avatar Max Greb avatar Simon Kusterer avatar Thomas Peklak avatar Everton Yoshitani avatar  avatar Aniket Pant avatar Brock Whitten avatar Daniel Levin avatar Dan Shaw avatar Mike Vegeto avatar  avatar Luke Arduini avatar heapwolf avatar stagas avatar Scott Elcomb avatar Nate Smith avatar

Watchers

 avatar heapwolf avatar timelyportfolio avatar James Cloos avatar  avatar

skateboard's Issues

need fallbacks

Instead of using websocket directly use engine.io or primus.

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.