diff options
| author | Sam Wilkins <samwilkins333@gmail.com> | 2020-01-09 18:31:03 -0500 |
|---|---|---|
| committer | Sam Wilkins <samwilkins333@gmail.com> | 2020-01-09 18:31:03 -0500 |
| commit | 6a45fd58601a2b03ed234f05b9b0a1b91d25a54d (patch) | |
| tree | 23bc7c4fa3ce4202a0f37fb1a561770dd155b6d6 /src/client | |
| parent | 13ad9e65697101574893a1fcdf49e018391d0d33 (diff) | |
azure ink fixes, session
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/DocServer.ts | 6 | ||||
| -rw-r--r-- | src/client/cognitive_services/CognitiveServices.ts | 9 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index 1723312cf..12fed3e46 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -64,13 +64,14 @@ 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. Please refresh your page in a few seconds, and expect to reconnect after about 30 seconds."); + 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. Please refresh your page in a few seconds, and expect to reconnect after about 30 seconds."); + 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."); @@ -78,6 +79,7 @@ export namespace DocServer { default: console.log(`Received an unknown ConnectionTerminated message: ${connectionTerminationReason}`); } + window.location.reload(); } export function init(protocol: string, hostname: string, port: number, identifier: string) { diff --git a/src/client/cognitive_services/CognitiveServices.ts b/src/client/cognitive_services/CognitiveServices.ts index 02eff3b25..57296c961 100644 --- a/src/client/cognitive_services/CognitiveServices.ts +++ b/src/client/cognitive_services/CognitiveServices.ts @@ -137,7 +137,7 @@ export namespace CognitiveServices { let id = 0; const strokes: AzureStrokeData[] = inkData.map(points => ({ id: id++, - points: points.map(({ x, y }) => `${x},${y}`).join(","), + points: points.map(({ X: x, Y: y }) => `${x},${y}`).join(","), language: "en-US" })); return JSON.stringify({ @@ -153,7 +153,7 @@ export namespace CognitiveServices { const serverAddress = "https://api.cognitive.microsoft.com"; const endpoint = serverAddress + "/inkrecognizer/v1.0-preview/recognize"; - const promisified = (resolve: any, reject: any) => { + return new Promise<string>((resolve, reject) => { xhttp.onreadystatechange = function () { if (this.readyState === 4) { const result = xhttp.responseText; @@ -171,11 +171,8 @@ export namespace CognitiveServices { xhttp.setRequestHeader('Ocp-Apim-Subscription-Key', apiKey); xhttp.setRequestHeader('Content-Type', 'application/json'); xhttp.send(body); - }; - - return new Promise<any>(promisified); + }); }, - }; export namespace Appliers { |
