catch socket connection error

This commit is contained in:
Evert Prants 2022-08-25 21:32:41 +03:00
parent b1b3be5e22
commit 836faee834
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 16 additions and 10 deletions

View File

@ -2,7 +2,7 @@
"main": "plugin.js",
"name": "syncplay",
"description": "Syncplay Service for Squeebot 3",
"version": "1.0.2",
"version": "1.0.3",
"tags": ["service", "syncplay"],
"dependencies": ["control?"],
"npmDependencies": []

View File

@ -196,16 +196,22 @@ class SyncplayProtocol extends Protocol {
password = crypto.createHash('md5').update(password).digest('hex');
}
this.socket = net.connect(opts, () => {
this.write({
Hello: {
username: this.config.syncplay.name,
password,
room: { name: this.config.syncplay.room },
version: PROTOCOL_VERSION
}
try {
this.socket = net.connect(opts, () => {
this.write({
Hello: {
username: this.config.syncplay.name,
password,
room: { name: this.config.syncplay.room },
version: PROTOCOL_VERSION
}
});
});
});
} catch(err: any) {
this.emit('error', err);
this.stop(true);
return;
}
let buffer: any = '';
this.socket.on('data', (chunk) => {