MCPcopy
hub / github.com/socketio/socket.io / initProxy

Function initProxy

examples/cluster-engine-redis/server.js:41–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39}
40
41function initProxy() {
42 const proxy = createProxyServer();
43
44 function randomTarget() {
45 return [
46 "http://localhost:3001",
47 "http://localhost:3002",
48 "http://localhost:3003",
49 ][Math.floor(Math.random() * 3)];
50 }
51
52 const httpServer = createServer((req, res) => {
53 proxy.web(req, res, { target: randomTarget() });
54 });
55
56 httpServer.on("upgrade", function (req, socket, head) {
57 proxy.ws(req, socket, head, { target: randomTarget() });
58 });
59
60 httpServer.listen(3000);
61}
62
63await Promise.all([initServer(3001), initServer(3002), initServer(3003)]);
64

Callers 1

server.jsFile · 0.85

Calls 4

createServerFunction · 0.85
randomTargetFunction · 0.85
listenMethod · 0.80
onMethod · 0.45

Tested by

no test coverage detected