[network] update

This commit is contained in:
2019-05-24 15:43:00 +03:00
parent 26ad5f47cd
commit 50a0cee044
19 changed files with 621 additions and 227 deletions

View File

@@ -21,13 +21,13 @@ class JsConnection<O:Message, I:Message> extends BaseConnection<O, I> {
this.port = port;
connected = false;
}
public static function isSecured():Bool {
return Browser.location.protocol == "https";
}
private function buildSocket(host:String, port:Int):WebSocket {
var protocol = switch Browser.location.protocol {
case 'http:': 'ws:';
case 'https:': 'wss:';
case _: 'ws:';
}
var protocol = isSecured() ? "wss:" : "ws:";
return new WebSocket('$protocol//$host:$port');
}