Skip to content

Commit a499a2d

Browse files
authored
Merge pull request #556 from witheve/fix-ping
all messages to the server should be an object
2 parents e2543f4 + 5fba7d9 commit a499a2d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export class EveClient {
214214
// ping the server so that the connection isn't overzealously
215215
// closed
216216
setInterval(() => {
217-
this.socketSend("\"PING\"");
217+
this.socketSend(JSON.stringify({type: "ping"}));
218218
}, 30000);
219219
}
220220

src/runtime/runtimeClient.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ export abstract class RuntimeClient {
9797

9898
handleEvent(json:string) {
9999
let data = JSON.parse(json);
100-
if(typeof data !== "object") throw new Error(data);
100+
101+
// Events are expected to be objects that have a type property
102+
// if they aren't, we toss the event out
103+
if(typeof data !== "object" || data.type === undefined) {
104+
console.error("Got invalid JSON event: " + json);
105+
return;
106+
}
107+
101108
if(data.type === "event") {
102109
if(!this.evaluation) return;
103110
// console.info("EVENT", json);

0 commit comments

Comments
 (0)