403Webshell
Server IP : 157.230.181.24  /  Your IP : 216.73.217.11
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/vhosts/convo/node_modules/tiny-lr-fork/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/convo/node_modules/tiny-lr-fork/lib/client.js
var util      = require('util');
var events    = require('events');
var WebSocket = require('faye-websocket');

module.exports = Client;

function Client(req, socket, head, options) {
  options = this.options = options || {};
  this.ws = new WebSocket(req, socket, head);
  this.ws.onmessage = this.message.bind(this);
  this.ws.onclose = this.close.bind(this);
  this.id = this.uniqueId('ws');
}

util.inherits(Client, events.EventEmitter);

Client.prototype.message = function message(event) {
  var data = this.data(event);
  if(this[data.command]) return this[data.command](data);
};

Client.prototype.close = function close(event) {
  if(this.ws) {
    this.ws.close();
    this.ws = null;
  }

  this.emit('end', event);
};

// Commands

Client.prototype.hello = function hello() {
  this.send({
    command: 'hello',
    protocols: [
      'http://livereload.com/protocols/official-7'
    ],
    serverName: 'tiny-lr'
  });
};

Client.prototype.info = function info(data) {
  this.plugins = data.plugins;
  this.url = data.url;
};

// Server commands

Client.prototype.reload = function reload(files) {
  files.forEach(function(file) {
    this.send({
      command: 'reload',
      path: file,
      liveCss: this.options.liveCss !== false,
      liveJs: this.options.liveJs !== false,
      liveImg: this.options.liveImg !== false
    });
  }, this);
};

// Utilities

Client.prototype.data = function _data(event) {
  var data = {};
  try {
    data = JSON.parse(event.data);
  } catch (e) {}
  return data;
};

Client.prototype.send = function send(data) {
  this.ws.send(JSON.stringify(data));
};

var idCounter = 0;
Client.prototype.uniqueId = function uniqueId(prefix) {
  var id = idCounter++;
  return prefix ? prefix + id : id;
};

Youez - 2016 - github.com/yon3zu
LinuXploit