diff options
| author | Sam Wilkins <samwilkins333@gmail.com> | 2020-01-09 18:08:56 -0500 |
|---|---|---|
| committer | Sam Wilkins <samwilkins333@gmail.com> | 2020-01-09 18:08:56 -0500 |
| commit | c809ac1cfddf71d95bdfb99c030e83579dd4e37b (patch) | |
| tree | 5eaa62b9f720ffe9f3839c579618f42fc2634a81 /src/client/DocServer.ts | |
| parent | 540bda7295f6ee7c2eed848598de6f5df74b2723 (diff) | |
unhandled rejection improvements and isSessionEnd flag
Diffstat (limited to 'src/client/DocServer.ts')
| -rw-r--r-- | src/client/DocServer.ts | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index ed7fbd7ba..1723312cf 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -64,6 +64,22 @@ export namespace DocServer { } } + function alertUser(connectionTerminationReason: string) { + switch (connectionTerminationReason) { + case "crash": + alert("Dash has temporarily crashed. Administrators have been notified and the server is restarting itself. Please refresh your page in a few seconds, and expect to reconnect after about 30 seconds."); + break; + case "temporary": + alert("An administrator has chosen to restart the server. Please refresh your page in a few seconds, and expect to reconnect after about 30 seconds."); + break; + case "exit": + alert("An administrator has chosen to kill the server. Do not expect to reconnect until administrators start the server."); + break; + default: + console.log(`Received an unknown ConnectionTerminated message: ${connectionTerminationReason}`); + } + } + export function init(protocol: string, hostname: string, port: number, identifier: string) { _cache = {}; GUID = identifier; @@ -82,9 +98,7 @@ export namespace DocServer { Utils.AddServerHandler(_socket, MessageStore.UpdateField, respondToUpdate); Utils.AddServerHandler(_socket, MessageStore.DeleteField, respondToDelete); Utils.AddServerHandler(_socket, MessageStore.DeleteFields, respondToDelete); - Utils.AddServerHandler(_socket, MessageStore.ConnectionTerminated, () => { - alert("Your connection to the server has been terminated."); - }); + Utils.AddServerHandler(_socket, MessageStore.ConnectionTerminated, alertUser); } function errorFunc(): never { |
