livereload-protocol

0.2.2 • Public • Published

LiveReload protocol parser

Handles LiveReload protocol handshake, validates and parses incoming commands, validates outgoing commands.

Synopsis

var Parser = require('livereload-parser');
parser = new Parser('server', { monitoring: [Parser.protocols.MONITORING_7] });
parser.on('error', function(err) {
  console.error('Error %s when parsing incoming message: %s', err.code, err.message);
  mywebsocket.close();
});
parser.on('connected', function() {
  console.log('Handshake done! Protocols: %j', parser.negotiatedProtocols);
  if (parser.negotiatedProtocols.monitoring >= 7) {
    console.log('TODO: activate monitoring here');
  }
});
parser.on('command', function(message) {
  console.log('Incoming command %s, data %j', message.command, message);
});
mywebsocket.on('data', function(data) {
  parser.received(data);
});

Installation

npm install livereload-protocol

Running tests

npm test

License

© 2012, Andrey Tarantsov, distributed under the MIT license.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.2
    1,284
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.2
    1,284
  • 0.2.1
    1
  • 0.2.0
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i livereload-protocol

Weekly Downloads

982

Version

0.2.2

License

none

Last publish

Collaborators

  • andreyvit