[common] udpate proto

This commit is contained in:
2018-03-01 12:05:06 +03:00
parent 634f5ad2d0
commit 45fab2c0b5
15 changed files with 96 additions and 63 deletions

View File

@@ -12,13 +12,13 @@ class NekoConnection<O:Message, I:Message> extends BaseConnection<O, I> {
public function new(socket:Socket, i:Class<I>) {
super(i);
this.socket = socket;
socket.setFastSend(true);
socket.output.bigEndian = false;
socket.input.bigEndian = false;
//socket.setFastSend(true);
//socket.output.bigEndian = false;
//socket.input.bigEndian = false;
sendHandler.connect(_send);
}
override public function send(packet:O):Void {
super.send(packet);
private function _send(packet:O):Void {
try {
var b = new BytesOutput();
packet.writeTo(b);
@@ -26,9 +26,8 @@ class NekoConnection<O:Message, I:Message> extends BaseConnection<O, I> {
socket.output.writeUInt16(bytes.length);
socket.output.write(bytes);
socket.output.flush();
} catch (e:Dynamic) {
trace("Error send packet: " + Type.getClassName(Type.getClass(packet)));
trace(e);
} catch (error:Dynamic) {
L.e('Proto', 'Error send packet: ${packet}', error);
}
}
}