public override void process() { Socket socket = _networkInterface.sock(); while (socket.Available > 0) { int length = 0; try { length = socket.Receive(_buffer); } catch (Exception e) { Dbg.ERROR_MSG("PacketReceiverKCP::process: " + e.ToString()); Event.fireIn("_closeNetwork", new object[] { _networkInterface }); return; } if (length <= 0) { Dbg.WARNING_MSG("PacketReceiverKCP::_asyncReceive(): KCP Receive <= 0!"); return; } ((NetworkInterfaceKCP)_networkInterface).nextTickKcpUpdate = 0; if (kcp_.Input(_buffer, 0, length) < 0) { Dbg.WARNING_MSG(string.Format("PacketReceiverKCP::_asyncReceive(): KCP Input get {0}!", length)); return; } while (true) { length = kcp_.Recv(_buffer, 0, _buffer.Length); if (length < 0) { break; } if (_networkInterface.fileter() != null) { _networkInterface.fileter().recv(_messageReader, _buffer, 0, (MessageLengthEx)length); } else { _messageReader.process(_buffer, 0, (MessageLengthEx)length); } } } }
public override void process() { Socket socket = _networkInterface.sock(); while (socket.Available > 0) { int length = 0; try { length = socket.Receive(_buffer); } catch (Exception e) { Dbg.ERROR_MSG("PacketReceiverKCP::process: " + e.ToString()); continue; } if (length <= 0) { Dbg.WARNING_MSG("PacketReceiverKCP::_asyncReceive(): KCP Receive <= 0!"); return; } if (kcp_.Input(_buffer, 0, length) < 0) { Dbg.WARNING_MSG(string.Format("PacketReceiverKCP::_asyncReceive(): KCP Input get {0}!", length)); return; } while (true) { length = kcp_.Recv(_buffer, 0, _buffer.Length); if (length <= 0) { break; } _messageReader.process(_buffer, 0, (MessageLengthEx)length); } } }