fixes
This commit is contained in:
@@ -97,11 +97,16 @@ class NetworkManager {
|
||||
}
|
||||
|
||||
private function onConnectionEvent(event:ConnectionEvent):Void {
|
||||
L.d('Network', '${event}');
|
||||
updateState(switch (event) {
|
||||
case ConnectionEvent.CONNECTED: 'connected';
|
||||
case ConnectionEvent.DISCONNECTED: 'offline';
|
||||
case ConnectionEvent.ERROR(error): 'error';
|
||||
case ConnectionEvent.CONNECTED:
|
||||
L.d('Network', '$event');
|
||||
'connected';
|
||||
case ConnectionEvent.DISCONNECTED:
|
||||
L.d('Network', '$event');
|
||||
'offline';
|
||||
case ConnectionEvent.ERROR(error):
|
||||
L.e('Network', '$error');
|
||||
'error';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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>> {
|
||||
|
||||
@@ -14,7 +14,7 @@ class ServerConfigBundle implements IConfigBundle {
|
||||
public function new() {}
|
||||
|
||||
public function get(type:GameType):Config {
|
||||
var path:String = FileSystem.absolutePath('./target/html5/resources/${type}/config.yaml');
|
||||
var path:String = FileSystem.absolutePath('./resources/${type}/config.yaml');
|
||||
var data:String = File.getContent(path);
|
||||
var source:ConfigSource = Yaml.parse(data, Parser.options().useObjects());
|
||||
return new Config(type, source.game, source.map, source.bricks, source.presets, source.points, source.tanks, source.bonuses);
|
||||
|
||||
@@ -13,7 +13,7 @@ class ServerLevelBundle implements ILevelBundle {
|
||||
public function new() {}
|
||||
|
||||
public function get(type:GameType, config:Config, level:Int):LevelConfig {
|
||||
var path:String = FileSystem.absolutePath('./target/html5/resources/${type}/levels/level${LevelUtil.formatLevel(level)}.txt');
|
||||
var path:String = FileSystem.absolutePath('./resources/${type}/levels/level${LevelUtil.formatLevel(level)}.txt');
|
||||
var data:String = File.getContent(path);
|
||||
return LevelUtil.loads(config, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user