MCPcopy Create free account
hub / github.com/Raynos/engine.io-stream / EngineServer

Function EngineServer

server.js:8–43  ·  view source on GitHub ↗
(onConnection)

Source from the content-addressed store, hash-verified

6module.exports = EngineServer
7
8function EngineServer(onConnection) {
9 var engine = new EventEmitter
10 var servers = []
11
12 engine.attach = attach
13 engine.close = close
14
15 if (onConnection) {
16 engine.on("connection", onConnection)
17 }
18
19 function attach(httpServer, options) {
20 options = options || {}
21
22 if (typeof options === "string") {
23 options = { path: options }
24 }
25
26 var server = EngineIO.attach(httpServer, options)
27
28 servers.push(server)
29
30 server.on("error", engine.emit.bind(engine, "error"));
31
32 server.on("connection", function (socket) {
33 engine.emit("connection", EngineStream(socket))
34 })
35 return server
36 }
37
38 function close() {
39 servers.forEach(invoke("close"))
40 }
41
42 return engine
43}
44
45function invoke(method) {
46 return function (obj) {

Callers 3

server.jsFile · 0.85
server.jsFile · 0.85
server.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected