style: format code

This commit is contained in:
2026-07-13 22:41:32 +03:00
parent b24c71678e
commit 0b24c03068
207 changed files with 7639 additions and 7816 deletions

View File

@@ -4,53 +4,52 @@ import protohx.Message;
import sys.net.Socket;
class NekoConnection<O:Message, I:Message> extends BaseConnection<O, I> {
public var socket(default, null):Socket;
public var socket(default, null):Socket;
private var sendQueue:Array<O>;
private var timer:Timer;
private var sendQueue:Array<O>;
private var timer:Timer;
public function new(socket:Socket, i:Class<I>) {
super(i);
this.socket = socket;
socket.setFastSend(true);
socket.output.bigEndian = false;
socket.input.bigEndian = false;
sendHandler.connect(pushPacket);
sendQueue = [];
timer = new Timer(1);
timer.run = sendRun;
}
public function new(socket:Socket, i:Class<I>) {
super(i);
this.socket = socket;
socket.setFastSend(true);
socket.output.bigEndian = false;
socket.input.bigEndian = false;
sendHandler.connect(pushPacket);
sendQueue = [];
timer = new Timer(1);
timer.run = sendRun;
private function sendPacket(packet:O):Void {
try {
var bytes = PacketUtil.toBytes(packet);
socket.output.writeUInt16(bytes.length);
socket.output.write(bytes);
socket.output.flush();
} catch (error:Dynamic) {
L.e('Proto', 'Error send packet: ${packet}', error);
}
}
private function sendPacket(packet:O):Void {
try {
var bytes = PacketUtil.toBytes(packet);
socket.output.writeUInt16(bytes.length);
socket.output.write(bytes);
socket.output.flush();
} catch (error:Dynamic) {
L.e('Proto', 'Error send packet: ${packet}', error);
}
private function sendRun():Void {
if (sendQueue.length > 0) {
for (packet in sendQueue) {
sendPacket(packet);
}
sendQueue = [];
}
}
private function sendRun():Void {
if (sendQueue.length > 0) {
for (packet in sendQueue) {
sendPacket(packet);
}
sendQueue = [];
}
}
private function pushPacket(packet:O):Void {
sendQueue.push(packet);
}
private function pushPacket(packet:O):Void {
sendQueue.push(packet);
}
override public function disconnect():Void {
if (timer != null) {
timer.stop();
timer = null;
}
super.disconnect();
override public function disconnect():Void {
if (timer != null) {
timer.stop();
timer = null;
}
super.disconnect();
}
}