Skip to content

Instantly share code, notes, and snippets.

@cazala
Created July 25, 2018 15:25
Show Gist options
  • Save cazala/d6bc8ae5ed0acd4fe95223fc53b610f1 to your computer and use it in GitHub Desktop.
Save cazala/d6bc8ae5ed0acd4fe95223fc53b610f1 to your computer and use it in GitHub Desktop.
// scene/server/Server.ts
import { connectedClients } from './ConnectedClients'
import { WebSocketTransport } from 'metaverse-api'
import RemoteScene from './RemoteScene'
+import store, { unregisterPlayer } from './Store'

 // ...

 wss.on('connection', function connection(ws, req) {
   connectedClients.add(client)
-  ws.on('close', () => connectedClients.delete(client))
+  ws.on('close', () => {
+    connectedClients.delete(client)
+    store.dispatch(unregisterPlayer(client.id))
+  })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment