[common] bullet with bricks collision
This commit is contained in:
38
src/common/haxe/ru/m/connect/neko/NekoConnection.hx
Executable file
38
src/common/haxe/ru/m/connect/neko/NekoConnection.hx
Executable file
@@ -0,0 +1,38 @@
|
||||
package ru.m.connect.neko;
|
||||
|
||||
import haxe.io.BytesOutput;
|
||||
import protohx.Message;
|
||||
import haxe.io.Bytes;
|
||||
import sys.net.Socket;
|
||||
import ru.m.connect.IConnection;
|
||||
|
||||
class NekoConnection extends BaseConnection {
|
||||
|
||||
public var socket(default, null):Socket;
|
||||
|
||||
public function new(socket:Socket) {
|
||||
super();
|
||||
this.socket = socket;
|
||||
socket.setFastSend(true);
|
||||
socket.output.bigEndian = false;
|
||||
socket.input.bigEndian = false;
|
||||
}
|
||||
|
||||
override public function send(packet:Message):Void {
|
||||
super.send(packet);
|
||||
try {
|
||||
var meta = builder.packetMeta(packet);
|
||||
var b = new BytesOutput();
|
||||
packet.writeTo(b);
|
||||
var bytes = b.getBytes();
|
||||
socket.output.writeByte(meta.family);
|
||||
socket.output.writeByte(meta.id);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user