fixes
This commit is contained in:
@@ -1,21 +1,13 @@
|
||||
package ru.m.connect.js;
|
||||
|
||||
import js.Browser;
|
||||
import js.html.WebSocket;
|
||||
import promhx.Promise;
|
||||
import protohx.Message;
|
||||
import ru.m.Base64;
|
||||
import ru.m.connect.IConnection.ConnectionEvent;
|
||||
|
||||
|
||||
typedef WebSocket = {
|
||||
var onopen:Dynamic -> Void;
|
||||
var onclose:Dynamic -> Void;
|
||||
var onmessage:Dynamic -> Void;
|
||||
var onerror:Dynamic -> Void;
|
||||
function send(message:String):Void;
|
||||
function emit(a:String, b:String):Void;
|
||||
function close():Void;
|
||||
}
|
||||
|
||||
class JsConnection<O:Message, I:Message> extends BaseConnection<O, I> {
|
||||
|
||||
private var host:String;
|
||||
@@ -30,7 +22,12 @@ class JsConnection<O:Message, I:Message> extends BaseConnection<O, I> {
|
||||
}
|
||||
|
||||
private function buildSocket(host:String, port:Int):WebSocket {
|
||||
return untyped __js__("new WebSocket('ws://'+host+':'+port);");
|
||||
var protocol = switch Browser.location.protocol {
|
||||
case 'http:': 'ws:';
|
||||
case 'https:': 'wss:';
|
||||
case _: 'ws:';
|
||||
}
|
||||
return new WebSocket('$protocol//$host:$port');
|
||||
}
|
||||
|
||||
override public function connect():Promise<IConnection<O, I>> {
|
||||
|
||||
Reference in New Issue
Block a user