Commit 892a4b84 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix parsing of server version.

parent 1ad91adf
...@@ -298,7 +298,7 @@ ServerConnection.prototype.connect = async function(url) { ...@@ -298,7 +298,7 @@ ServerConnection.prototype.connect = async function(url) {
this.socket.onopen = function(e) { this.socket.onopen = function(e) {
sc.send({ sc.send({
type: 'handshake', type: 'handshake',
version: ["2"], version: ['2'],
id: sc.id, id: sc.id,
}); });
if(sc.onconnected) if(sc.onconnected)
...@@ -332,9 +332,10 @@ ServerConnection.prototype.connect = async function(url) { ...@@ -332,9 +332,10 @@ ServerConnection.prototype.connect = async function(url) {
let m = JSON.parse(e.data); let m = JSON.parse(e.data);
switch(m.type) { switch(m.type) {
case 'handshake': { case 'handshake': {
if(m.version === "2") if((m.version instanceof Array) && m.version.includes('2')) {
sc.version = m.version; sc.version = '2';
else { } else {
sc.version = null;
console.error(`Unknown protocol version ${m.version}`); console.error(`Unknown protocol version ${m.version}`);
throw new Error(`Unknown protocol version ${m.version}`); throw new Error(`Unknown protocol version ${m.version}`);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment