Last active
May 16, 2018 22:14
-
-
Save cazala/4f9e883813c94965a2157745a8a59b28 to your computer and use it in GitHub Desktop.
Decentraland Shoal Scene - Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Server | |
const app = require('express')() | |
const server = require('http').createServer(app) | |
const wss = new WebSocketServer({ server }) | |
const clients: Set<RemoteScene> = new Set() | |
wss.on('connection', (ws, req) => { | |
const transport = WebSocketTransport(ws) | |
const client = new RemoteScene(transport) | |
clients.add(client) | |
client.on('error', (err: Error) => ws.close()) | |
ws.on('close', () => clients.delete(client)) | |
}) | |
server.listen(8087, () => console.log(`Listening on 8087`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment