()
| 100 | } |
| 101 | |
| 102 | async function init() { |
| 103 | const redisClient = await initRedisClient(); |
| 104 | |
| 105 | const httpServer = createServer(); |
| 106 | const io = new Server(httpServer, { |
| 107 | adapter: createAdapter(redisClient, { |
| 108 | readCount: 1, // return as soon as possible |
| 109 | }), |
| 110 | }); |
| 111 | |
| 112 | return new Promise<{ |
| 113 | io: Server; |
| 114 | socket: ServerSocket; |
| 115 | clientSocket: ClientSocket; |
| 116 | cleanup: () => void; |
| 117 | }>((resolve) => { |
| 118 | httpServer.listen(() => { |
| 119 | const port = (httpServer.address() as AddressInfo).port; |
| 120 | const clientSocket = ioc(`http://localhost:${port}`); |
| 121 | |
| 122 | io.on("connection", async (socket) => { |
| 123 | resolve({ |
| 124 | io, |
| 125 | socket, |
| 126 | clientSocket, |
| 127 | cleanup: () => { |
| 128 | io.close(); |
| 129 | clientSocket.disconnect(); |
| 130 | redisClient.quit(); |
| 131 | }, |
| 132 | }); |
| 133 | }); |
| 134 | }); |
| 135 | }); |
| 136 | } |
| 137 | |
| 138 | export async function setup() { |
| 139 | const results = await Promise.all([init(), init(), init()]); |
no test coverage detected