Browse Source

remove remote pointers on client disconnect

dwelle 5 years ago
parent
commit
96320478e6
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/components/App.tsx

+ 6 - 0
src/components/App.tsx

@@ -340,6 +340,12 @@ export class App extends React.Component<any, AppState> {
       this.socket.on("room-user-count", (collaboratorCount: number) => {
       this.socket.on("room-user-count", (collaboratorCount: number) => {
         this.setState({ collaboratorCount });
         this.setState({ collaboratorCount });
       });
       });
+      this.socket.on("client-disconnected", (socketID: number) => {
+        this.setState(state => {
+          const { [socketID]: omit, ...remotePointers } = state.remotePointers;
+          return { remotePointers };
+        });
+      });
       this.socket.on("new-user", async (socketID: string) => {
       this.socket.on("new-user", async (socketID: string) => {
         this.broadcastSocketData({
         this.broadcastSocketData({
           type: "SCENE_UPDATE",
           type: "SCENE_UPDATE",