How to use the type.createServer function in type

To help you get started, we’ve selected a few type 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 dthree / vantage / lib / server.js View on Github external
if (this.server.connections.length === 0) {
      this.server.connection({ port: options.port, labels: "vantage" });
      this.io = require("socket.io")(this.server.listener);
    } else if (this.server.connections.length > 1) {
      // Select a specific connection if more than one exist.
      this.io = require("socket.io")(this.server.select(options.connectionLabel || "vantage").listener);
      delete options.connectionLabel;
    } else {
      this.io = require("socket.io")(this.server.listener);
    }
  } else {
    var type = (options.ssl) ? "https" : "http";
    if (type === "http") {
      this.server = require(type).createServer(appCallback);
    } else {
      this.server = require(type).createServer(options, appCallback);
    }
    this.io = require("socket.io")(this.server);
    this.server.listen(options.port);
  }

  this._port = options.port;
  this._logActivity = options.logActivity;

  this.io.set("authorization", function(handshakeData, accept){

    var address = handshakeData.connection._peername;
    var valid = self.firewall.valid(address);
    var query = handshakeData._query;
    var id = query.id || void 0;
    var ssnId = query.sessionId || void 0;
github dthree / vantage / lib / server.js View on Github external
// Create a connection if none exist.
    if (this.server.connections.length === 0) {
      this.server.connection({ port: options.port, labels: "vantage" });
      this.io = require("socket.io")(this.server.listener);
    } else if (this.server.connections.length > 1) {
      // Select a specific connection if more than one exist.
      this.io = require("socket.io")(this.server.select(options.connectionLabel || "vantage").listener);
      delete options.connectionLabel;
    } else {
      this.io = require("socket.io")(this.server.listener);
    }
  } else {
    var type = (options.ssl) ? "https" : "http";
    if (type === "http") {
      this.server = require(type).createServer(appCallback);
    } else {
      this.server = require(type).createServer(options, appCallback);
    }
    this.io = require("socket.io")(this.server);
    this.server.listen(options.port);
  }

  this._port = options.port;
  this._logActivity = options.logActivity;

  this.io.set("authorization", function(handshakeData, accept){

    var address = handshakeData.connection._peername;
    var valid = self.firewall.valid(address);
    var query = handshakeData._query;
    var id = query.id || void 0;