8a023531 by Glitch (hello-express)

:cop::grapes: Checkpoint

./server.js:13690106/274
1 parent 4cd6a320
Showing 1 changed file with 13 additions and 7 deletions
1 var Gun = require('gun'); 1 const url = require('url');
2 var http = require('http'); 2 const Gun = require('gun');
3 var server = http.createServer().listen(300); 3 const http = require('http');
4 var wss_event = new WebSocket.Server({ 4 const WebSocket = require('ws');
5 noServer: true 5 var server = http.createServer().listen(3000);
6 }); 6
7 var wss_event = new WebSocket.Server({ noServer: true});
8
7 server.on('upgrade', function (request, socket, head) { 9 server.on('upgrade', function (request, socket, head) {
8 var pathname = url.parse(request.url).pathname; 10 var pathname = url.parse(request.url).pathname;
9 if (pathname === '/sim_world') { 11 if (pathname === '/gun1') {
12 wss_event.handleUpgrade(request, socket, head, function (ws) {
13 wss_event.emit('connection', ws);
14 });
15 } else if (pathname === '/gun2') {
10 wss_event.handleUpgrade(request, socket, head, function (ws) { 16 wss_event.handleUpgrade(request, socket, head, function (ws) {
11 wss_event.emit('connection', ws); 17 wss_event.emit('connection', ws);
12 }); 18 });
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!