1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.protocol = exports.Transport = exports.Socket = exports.uServer = exports.parser = exports.attach = exports.listen = exports.transports = exports.Server = void 0;
|
---|
4 | const http_1 = require("http");
|
---|
5 | const server_1 = require("./server");
|
---|
6 | Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return server_1.Server; } });
|
---|
7 | const index_1 = require("./transports/index");
|
---|
8 | exports.transports = index_1.default;
|
---|
9 | const parser = require("engine.io-parser");
|
---|
10 | exports.parser = parser;
|
---|
11 | var userver_1 = require("./userver");
|
---|
12 | Object.defineProperty(exports, "uServer", { enumerable: true, get: function () { return userver_1.uServer; } });
|
---|
13 | var socket_1 = require("./socket");
|
---|
14 | Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_1.Socket; } });
|
---|
15 | var transport_1 = require("./transport");
|
---|
16 | Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return transport_1.Transport; } });
|
---|
17 | exports.protocol = parser.protocol;
|
---|
18 | /**
|
---|
19 | * Creates an http.Server exclusively used for WS upgrades.
|
---|
20 | *
|
---|
21 | * @param {Number} port
|
---|
22 | * @param {Function} callback
|
---|
23 | * @param {Object} options
|
---|
24 | * @return {Server} websocket.io server
|
---|
25 | * @api public
|
---|
26 | */
|
---|
27 | function listen(port, options, fn) {
|
---|
28 | if ("function" === typeof options) {
|
---|
29 | fn = options;
|
---|
30 | options = {};
|
---|
31 | }
|
---|
32 | const server = (0, http_1.createServer)(function (req, res) {
|
---|
33 | res.writeHead(501);
|
---|
34 | res.end("Not Implemented");
|
---|
35 | });
|
---|
36 | // create engine server
|
---|
37 | const engine = attach(server, options);
|
---|
38 | engine.httpServer = server;
|
---|
39 | server.listen(port, fn);
|
---|
40 | return engine;
|
---|
41 | }
|
---|
42 | exports.listen = listen;
|
---|
43 | /**
|
---|
44 | * Captures upgrade requests for a http.Server.
|
---|
45 | *
|
---|
46 | * @param {http.Server} server
|
---|
47 | * @param {Object} options
|
---|
48 | * @return {Server} engine server
|
---|
49 | * @api public
|
---|
50 | */
|
---|
51 | function attach(server, options) {
|
---|
52 | const engine = new server_1.Server(options);
|
---|
53 | engine.attach(server, options);
|
---|
54 | return engine;
|
---|
55 | }
|
---|
56 | exports.attach = attach;
|
---|