From 96f7938e5f5b9d2666ed1f89777bd9af4ed7d286 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 22 Nov 2023 19:59:54 +0900 Subject: [PATCH] [test] close peer --- src/ts/sync/multiuser.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ts/sync/multiuser.ts b/src/ts/sync/multiuser.ts index 8634fc2f..cc114af8 100644 --- a/src/ts/sync/multiuser.ts +++ b/src/ts/sync/multiuser.ts @@ -35,6 +35,7 @@ export async function createMultiuserRoom(){ peer.on('connection', function(conn) { connections.push(conn) console.log("new connection", conn) + function requestChar(){ const db = get(DataBase) const selectedCharId = get(selectedCharID) @@ -65,6 +66,15 @@ export async function createMultiuserRoom(){ sendPeerChar() } }); + + conn.on('close', function() { + for(let i = 0; i < connections.length; i++){ + if(connections[i].connectionId === conn.connectionId){ + connections.splice(i, 1) + break + } + } + }) }); while(!open){ await sleep(100)