diff options
author | Tyler Schicke <tschicke@gmail.com> | 2020-01-09 21:33:18 -0800 |
---|---|---|
committer | Tyler Schicke <tschicke@gmail.com> | 2020-01-09 21:33:18 -0800 |
commit | 2295ab2500487da6b030d871b8d81724a4ddada3 (patch) | |
tree | cc4bff122cd18066521affb382c0e93cde9b33ce /src/client/DocServer.ts | |
parent | 786d25a4f8db1db8795f04a17fba392636e5f891 (diff) | |
parent | a8aa0facfaa23298398c15aa906bc6d69c538564 (diff) |
Merge branch 'master' of github.com:browngraphicslab/Dash-Web into no_db
Diffstat (limited to 'src/client/DocServer.ts')
-rw-r--r-- | src/client/DocServer.ts | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index dbe8e58b9..d793b56af 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -64,6 +64,24 @@ export namespace DocServer { } } + const instructions = "This page will automatically refresh after this alert is closed. Expect to reconnect after about 30 seconds."; + function alertUser(connectionTerminationReason: string) { + switch (connectionTerminationReason) { + case "crash": + alert(`Dash has temporarily crashed. Administrators have been notified and the server is restarting itself. ${instructions}`); + break; + case "temporary": + alert(`An administrator has chosen to restart the server. ${instructions}`); + 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}`); + } + window.location.reload(); + } + export function init(protocol: string, hostname: string, port: number, identifier: string) { _cache = {}; GUID = identifier; @@ -82,7 +100,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 { |