Skip to content

Commit b10ae48

Browse files
committed
Test with error
1 parent a6cd432 commit b10ae48

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jderobot-commsmanager",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"main": "dist/main.js",
55
"typings": "dist/index.d.ts",
66
"scripts": {

src/components/CommsManager.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,27 @@ export default class CommsManager {
6363
);
6464
} else {
6565
console.log(`Connection with ${CommsManager.adress} interrupted`);
66-
setTimeout(function() {
66+
setTimeout(function () {
6767
delete CommsManager.instance;
6868
CommsManager.instance = new CommsManager();
6969
}, 1000);
7070
}
7171
};
72+
73+
this.ws.onerror = (e: any) => {
74+
console.error("Socket encountered error: ", e.message, "Closing socket");
75+
this.ws.close();
76+
setTimeout(function () {
77+
delete CommsManager.instance;
78+
CommsManager.instance = new CommsManager();
79+
}, 1000);
80+
};
7281
}
7382

7483
// Singleton behavior
7584
public static getInstance(address?: string): CommsManager {
7685
if (!CommsManager.instance) {
77-
CommsManager.adress = address ? address : "ws://127.0.0.1:7163"
86+
CommsManager.adress = address ? address : "ws://127.0.0.1:7163";
7887
CommsManager.instance = new CommsManager();
7988
}
8089
return CommsManager.instance;

0 commit comments

Comments
 (0)