[common] udpate proto
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package ru.m.tankz.network;
|
||||
|
||||
import haxework.provider.Provider;
|
||||
import hxsignal.impl.Signal1;
|
||||
import ru.m.connect.IConnection;
|
||||
import ru.m.signal.Signal;
|
||||
import ru.m.tankz.proto.pack.LoginRequest;
|
||||
import ru.m.tankz.proto.pack.Request;
|
||||
import ru.m.tankz.proto.pack.Response;
|
||||
@@ -14,7 +14,7 @@ typedef ClientConnection = IConnection<Request, Response>;
|
||||
class NetworkManager {
|
||||
|
||||
public var state(default, null):String;
|
||||
public var stateSignal:Signal1<String>;
|
||||
public var stateSignal:Signal<String>;
|
||||
public var user(default, null):User;
|
||||
|
||||
private var connection(get, never):ClientConnection;
|
||||
@@ -29,10 +29,10 @@ class NetworkManager {
|
||||
}
|
||||
|
||||
public function new() {
|
||||
stateSignal = new Signal1<String>();
|
||||
stateSignal = new Signal<String>();
|
||||
updateState('offline');
|
||||
connection.handler.connect(onConnectionEvent);
|
||||
connection.packetHandler.connect(onResponse);
|
||||
connection.receiveHandler.connect(onResponse);
|
||||
user = storage.read();
|
||||
if (user == null) {
|
||||
user = {name: 'User', uuid: null};
|
||||
@@ -58,7 +58,12 @@ class NetworkManager {
|
||||
}
|
||||
|
||||
private function onConnectionEvent(event:ConnectionEvent):Void {
|
||||
updateState(Std.string(event));
|
||||
L.d('Network', '${event}');
|
||||
updateState(switch (event) {
|
||||
case ConnectionEvent.CONNECTED: 'connected';
|
||||
case ConnectionEvent.DISCONNECTED: 'offline';
|
||||
case ConnectionEvent.ERROR(error): 'error';
|
||||
});
|
||||
}
|
||||
|
||||
private function onResponse(packet:Response):Void {
|
||||
|
||||
Reference in New Issue
Block a user