How to use the spdy.Connection function in spdy

To help you get started, we’ve selected a few spdy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zettajs / zetta / lib / peer_client.js View on Github external
var EventEmitter = require('events').EventEmitter;
var path = require('path');
var util = require('util');
var uuid = require('uuid');
var spdy = require('spdy');
var Logger = require('./logger');
var WebSocket = require('./web_socket');

// monkey patch spdy connection to get access to ping event
var originalPingHandler = spdy.Connection.prototype._handlePing;
spdy.Connection.prototype._handlePing = function() {
  this.socket.emit('spdyPing', this);
  originalPingHandler.apply(this, arguments);
};

function calculatePeerUrl(url, name){
 var wsUrl = url.replace(/^http/, 'ws');
  var peerPath = '/peers/' + name;
  if(wsUrl.indexOf('/', wsUrl.length - 1) === -1)  {
    wsUrl = wsUrl + peerPath;
  } else {
    wsUrl = wsUrl.slice(0, wsUrl.length - 1) + peerPath;
  }
  return wsUrl;
}

var PeerClient = module.exports = function(url, server) {
github zettajs / zetta / lib / peer_client.js View on Github external
var EventEmitter = require('events').EventEmitter;
var path = require('path');
var util = require('util');
var uuid = require('uuid');
var spdy = require('spdy');
var Logger = require('./logger');
var WebSocket = require('./web_socket');

// monkey patch spdy connection to get access to ping event
var originalPingHandler = spdy.Connection.prototype._handlePing;
spdy.Connection.prototype._handlePing = function() {
  this.socket.emit('spdyPing', this);
  originalPingHandler.apply(this, arguments);
};

function calculatePeerUrl(url, name){
 var wsUrl = url.replace(/^http/, 'ws');
  var peerPath = '/peers/' + name;
  if(wsUrl.indexOf('/', wsUrl.length - 1) === -1)  {
    wsUrl = wsUrl + peerPath;
  } else {
    wsUrl = wsUrl.slice(0, wsUrl.length - 1) + peerPath;
  }
  return wsUrl;
}

spdy

Implementation of the SPDY protocol on node.js.

MIT
Latest version published 5 years ago

Package Health Score

76 / 100
Full package analysis