[client] hostname from environ
This commit is contained in:
@@ -16,4 +16,9 @@
|
|||||||
file:
|
file:
|
||||||
src: "{{ release_dir }}"
|
src: "{{ release_dir }}"
|
||||||
dest: "{{ project_dir }}/current"
|
dest: "{{ project_dir }}/current"
|
||||||
state: link
|
state: link
|
||||||
|
|
||||||
|
- name: "restart {{ project_name }} service"
|
||||||
|
systemd:
|
||||||
|
state: restarted
|
||||||
|
name: "{{ project_name }}"
|
||||||
|
|||||||
@@ -19,10 +19,31 @@ import ru.m.tankz.proto.pack.Response;
|
|||||||
import ru.m.tankz.sound.SoundManager;
|
import ru.m.tankz.sound.SoundManager;
|
||||||
import ru.m.tankz.storage.SaveStorage;
|
import ru.m.tankz.storage.SaveStorage;
|
||||||
import ru.m.tankz.storage.UserStorage;
|
import ru.m.tankz.storage.UserStorage;
|
||||||
|
#if flash
|
||||||
|
import flash.Lib;
|
||||||
|
#elseif html5
|
||||||
|
import js.Browser;
|
||||||
|
#end
|
||||||
|
|
||||||
|
|
||||||
class Init {
|
class Init {
|
||||||
|
|
||||||
|
private static function getHost():String {
|
||||||
|
#if flash
|
||||||
|
var url = Lib.current.loaderInfo.url;
|
||||||
|
var r:EReg = ~/((app|https?):\/\/?[-_\w\d\.]+(:\d+)?)\/?/;
|
||||||
|
if (r.match(url) && !(r.matched(2) == "app")) {
|
||||||
|
return r.matched(1);
|
||||||
|
} else {
|
||||||
|
return "localhost";
|
||||||
|
}
|
||||||
|
#elseif html5
|
||||||
|
return Browser.location.hostname;
|
||||||
|
#else
|
||||||
|
return "localhost";
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
public static function init():Void {
|
public static function init():Void {
|
||||||
Provider.setFactory(IResources, Resources);
|
Provider.setFactory(IResources, Resources);
|
||||||
Provider.setFactory(ILevelBundle, LevelBundle);
|
Provider.setFactory(ILevelBundle, LevelBundle);
|
||||||
@@ -35,10 +56,12 @@ class Init {
|
|||||||
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
||||||
Provider.setFactory(Game, DotaGame, DotaGame.TYPE);
|
Provider.setFactory(Game, DotaGame, DotaGame.TYPE);
|
||||||
|
|
||||||
|
var host:String = getHost();
|
||||||
|
L.d('Init', 'host: ${host}');
|
||||||
#if flash
|
#if flash
|
||||||
Provider.set(IConnection, new ru.m.connect.flash.FlashConnection<Request, Response>('localhost', 5001, Response));
|
Provider.set(IConnection, new ru.m.connect.flash.FlashConnection<Request, Response>(host, 5000, Response));
|
||||||
#elseif html5
|
#elseif html5
|
||||||
Provider.set(IConnection, new ru.m.connect.js.JsConnection<Request, Response>('localhost', 5001, Response));
|
Provider.set(IConnection, new ru.m.connect.js.JsConnection<Request, Response>(host, 5000, Response));
|
||||||
#else
|
#else
|
||||||
Provider.set(IConnection, new ru.m.connect.fake.FakeConnection<Request, Response>(Response));
|
Provider.set(IConnection, new ru.m.connect.fake.FakeConnection<Request, Response>(Response));
|
||||||
#end
|
#end
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class JsConnection<O:Message, I:Message> extends BaseConnection<O, I> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function buildSocket(host:String, port:Int):WebSocket {
|
private function buildSocket(host:String, port:Int):WebSocket {
|
||||||
return untyped __js__('new WebSocket("ws://${host}:${port}");');
|
return untyped __js__("new WebSocket('ws://'+host+':'+port);");
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function connect():Promise<IConnection<O, I>> {
|
override public function connect():Promise<IConnection<O, I>> {
|
||||||
|
|||||||
@@ -58,6 +58,6 @@ class Server extends ThreadServer<Session, Bytes> {
|
|||||||
Provider.setFactory(ILevelBundle, ServerLevelBundle);
|
Provider.setFactory(ILevelBundle, ServerLevelBundle);
|
||||||
Provider.setFactory(IControlFactory, NoneControlFactory);
|
Provider.setFactory(IControlFactory, NoneControlFactory);
|
||||||
var wserver = new Server();
|
var wserver = new Server();
|
||||||
wserver.run("localhost", 5001);
|
wserver.run("localhost", 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user