public void SendPacket(NetSendPacket packet) { packet._Client = this; if (!NetOpcode.Send.ContainsKey(packet.GetType())) { Log.Warn("UNKNOWN packet opcode: {0}", packet.GetType().Name); return; } try { packet.WriteH(0); // packet len packet.WriteH(NetOpcode.Send[packet.GetType()]); // opcode packet.Write(); byte[] Data = packet.ToByteArray(); BitConverter.GetBytes((short)(Data.Length - 2)).CopyTo(Data, 0); Log.Debug("Send: {0}", Data.FormatHex()); this._stream.BeginWrite(Data, 0, Data.Length, new AsyncCallback(EndSendCallBackStatic), (object)null); } catch (Exception ex) { Log.Warn("Can't send packet: {0}", GetType().Name); Log.WarnException("ASendPacket", ex); return; } }