better error handling

This commit is contained in:
Lamp 2018-11-26 14:17:13 -08:00
parent 94836b1f43
commit 0314829353
No known key found for this signature in database
GPG Key ID: 0F1F8704BEDE369E
2 changed files with 2 additions and 3 deletions

View File

@ -111,10 +111,8 @@ Client.prototype.connect = function() {
setTimeout(self.connect.bind(self), ms);
});
this.ws.addEventListener("error", function(error) {
console.error(error.toString());
self.emit("error", error);
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) {
self.connectionTime = Date.now();

View File

@ -43,6 +43,7 @@ global.createMPPbridge = function createMPPbridge(room, DiscordChannelID, site =
site == "CMPC" ? new Client("ws://charsy.meowbin.com:16562") :
undefined;
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.start();