forcefully disconnect from server

This commit is contained in:
Vitaly 2023-09-07 06:17:32 +03:00
commit a360b2eee3
2 changed files with 6 additions and 2 deletions

View file

@ -71,7 +71,7 @@ class PauseScreen extends LitElement {
<pmui-button pmui-width="98px" pmui-label="Discord" @pmui-click=${() => openURL('https://discord.gg/4Ucm684Fq3')}></pmui-button>
</div>
<pmui-button pmui-width="204px" pmui-label="Options" @pmui-click=${() => showModal(document.getElementById('options-screen'))}></pmui-button>
<pmui-button pmui-width="204px" pmui-label="${!fsState.syncFs && !fsState.isReadonly ? 'Save & Quit' : 'Disconnect'}" @pmui-click=${async () => {
<pmui-button pmui-width="204px" pmui-label="${localServer && !fsState.syncFs && !fsState.isReadonly ? 'Save & Quit' : 'Disconnect'}" @pmui-click=${async () => {
disconnect()
}}></pmui-button>
</main>

View file

@ -153,8 +153,12 @@ export const disconnect = async () => {
if (window.localServer) {
await saveWorld()
localServer.quit()
} else {
// workaround bot.end doesn't end the socket and emit end event
bot.end()
bot._client.socket.end()
}
bot._client.emit('end')
bot._client.emit('end', 'You left the server')
miscUiState.gameLoaded = false
}