xref: /unit/test/node/loader/es_modules_websocket/app.mjs (revision 1876:f85b85094541)
1import http from "http"
2import websocket from "websocket"
3
4let server = http.createServer(function() {});
5let webSocketServer = websocket.server;
6
7server.listen(7080, function() {});
8
9var wsServer = new webSocketServer({
10    maxReceivedMessageSize: 0x1000000000,
11    maxReceivedFrameSize: 0x1000000000,
12    fragmentOutgoingMessages: false,
13    fragmentationThreshold: 0x1000000000,
14    httpServer: server,
15});
16
17wsServer.on('request', function(request) {
18    var connection = request.accept(null);
19
20    connection.on('message', function(message) {
21        if (message.type === 'utf8') {
22            connection.send(message.utf8Data);
23        } else if (message.type === 'binary') {
24            connection.send(message.binaryData);
25        }
26
27  });
28
29  connection.on('close', function(r) {});
30});
31