(port)
| 8 | const { createProxyServer } = proxyModule; |
| 9 | |
| 10 | async function initServer(port) { |
| 11 | const httpServer = createServer((req, res) => { |
| 12 | res.writeHead(404).end(); |
| 13 | }); |
| 14 | |
| 15 | const pubClient = createClient(); |
| 16 | const subClient = pubClient.duplicate(); |
| 17 | |
| 18 | await Promise.all([pubClient.connect(), subClient.connect()]); |
| 19 | |
| 20 | const engine = new RedisEngine(pubClient, subClient); |
| 21 | |
| 22 | engine.attach(httpServer, { |
| 23 | path: class="st">"/socket.io/", |
| 24 | }); |
| 25 | |
| 26 | const io = new Server({ |
| 27 | adapter: createAdapter(pubClient, subClient), |
| 28 | }); |
| 29 | |
| 30 | io.bind(engine); |
| 31 | |
| 32 | io.on(class="st">"connection", (socket) => { |
| 33 | socket.on(class="st">"hello", () => { |
| 34 | socket.broadcast.emit(class="st">"hello", socket.id, port); |
| 35 | }); |
| 36 | }); |
| 37 | |
| 38 | httpServer.listen(port); |
| 39 | } |
| 40 | |
| 41 | function initProxy() { |
| 42 | const proxy = createProxyServer(); |
no test coverage detected