Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (42 sloc) 0.965 kB

skates

opinions:

  • WebSocket based apps needs to be on ecosystem, like connect, express.
  • WebSocket other websocket frameworks are too monolithic.
  • make your life easy: use a module bundler on the client

this is all you need:

//client.js
var emitter = require('skates')()

setInterval(function () {
  emitter.emit('ping', Date.now())
}, 1e3)
emitter.on('pong', function (time) {
  console.log('latency:', time)
})

and this:

//server.js
var skates = require('skates')
var connect = require('connect')
var app = skates.createServer()
  .use(connect.static('public')
  .on('connection', function (emitter) {
    emitter.on('ping', function (time) {
      emitter.emit('pong', Date.now() - time)
    })

  })
  .listen(3000)

too easy.

oh, yeah.

<!-- public/index.html -->
<!doctype html>
<html>
  <head>
    <script src=/browserify.js></script>
  </head>
</html>

then node server & google-chrome localhost:3000

Jump to Line
Something went wrong with that request. Please try again.