Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

dominictarr/client-reloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

client-reloader

Reload client sessions, when they connect with an old client js. recommended use with reconnect and shoe or other client-side stream api.

Example

Client

var reconnect = require('reconnect')
var reloader  = require('client-reloader')

reconnect(reloader(function (stream) {
  //your good! use the stream!
}, meta)).connect('/shoe')

When the client reconnects, the server will send the current version, if it is different to the server version, the client will reload.

Server

var shoe = require('shoe')
var reloader = require('client-reloader')
var ecstatic = require('ecstatic')

shoe(reloader(function (stream) {
  //the client has successfull connected, 
  //with the right version!

  //also, here is the metadata passed from the client.
  console.log(stream.meta)
}), VERSION).install(
  //serve static files.
  http.createServer(ecstatic(__dirname+'/static'))
  .listen(PORT)
, '/shoe')

VERSION is optional. If this is not defined it will default to the timestamp that you started the server. This will make clients restart whenever you restart the server. (probably good behaviour for dev mode)

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published