better error handling
This commit is contained in:
parent
94836b1f43
commit
0314829353
|
@ -111,10 +111,8 @@ Client.prototype.connect = function() {
|
||||||
setTimeout(self.connect.bind(self), ms);
|
setTimeout(self.connect.bind(self), ms);
|
||||||
});
|
});
|
||||||
this.ws.addEventListener("error", function(error) {
|
this.ws.addEventListener("error", function(error) {
|
||||||
console.error(error.toString());
|
self.emit("error", error);
|
||||||
self.ws.emit("close");
|
self.ws.emit("close");
|
||||||
//self.emit('disconnect', error.toString()); //TODO
|
|
||||||
//if (error.toString() == "Error: unexpected server response (403)") process.exit();
|
|
||||||
});
|
});
|
||||||
this.ws.addEventListener("open", function(evt) {
|
this.ws.addEventListener("open", function(evt) {
|
||||||
self.connectionTime = Date.now();
|
self.connectionTime = Date.now();
|
||||||
|
|
|
@ -43,6 +43,7 @@ global.createMPPbridge = function createMPPbridge(room, DiscordChannelID, site =
|
||||||
site == "CMPC" ? new Client("ws://charsy.meowbin.com:16562") :
|
site == "CMPC" ? new Client("ws://charsy.meowbin.com:16562") :
|
||||||
undefined;
|
undefined;
|
||||||
if (!gClient) return console.error(`Invalid site ${site}`);
|
if (!gClient) return console.error(`Invalid site ${site}`);
|
||||||
|
gClient.on("error", error => console.error(`[${site}][${room}]`, error.message))
|
||||||
gClient.setChannel(/*(site == "MPP" && room == "lobby") ? "lolwutsecretlobbybackdoor" : */room);
|
gClient.setChannel(/*(site == "MPP" && room == "lobby") ? "lolwutsecretlobbybackdoor" : */room);
|
||||||
gClient.start();
|
gClient.start();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue