Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
19 changed files
with
482 additions
and
1,130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
npm-debug.log | ||
build/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { createServer } from "http"; | ||
import { Server, AttachOptions, ServerOptions } from "./server"; | ||
import transports from "./transports/index"; | ||
import * as parser from "engine.io-parser"; | ||
|
||
export { Server, transports, listen, attach, parser }; | ||
export { AttachOptions, ServerOptions } from "./server"; | ||
export { Socket } from "./socket"; | ||
export { Transport } from "./transport"; | ||
export const protocol = parser.protocol; | ||
|
||
/** | ||
* Creates an http.Server exclusively used for WS upgrades. | ||
* | ||
* @param {Number} port | ||
* @param {Function} callback | ||
* @param {Object} options | ||
* @return {Server} websocket.io server | ||
* @api public | ||
*/ | ||
|
||
function listen(port, options: AttachOptions & ServerOptions, fn) { | ||
if ("function" === typeof options) { | ||
fn = options; | ||
options = {}; | ||
} | ||
|
||
const server = createServer(function(req, res) { | ||
res.writeHead(501); | ||
res.end("Not Implemented"); | ||
}); | ||
|
||
// create engine server | ||
const engine = attach(server, options); | ||
engine.httpServer = server; | ||
|
||
server.listen(port, fn); | ||
|
||
return engine; | ||
} | ||
|
||
/** | ||
* Captures upgrade requests for a http.Server. | ||
* | ||
* @param {http.Server} server | ||
* @param {Object} options | ||
* @return {Server} engine server | ||
* @api public | ||
*/ | ||
|
||
function attach(server, options: AttachOptions & ServerOptions) { | ||
const engine = new Server(options); | ||
engine.attach(server, options); | ||
return engine; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.