public int WriteToFile(G2Packet packet, Stream stream) { byte[] data = packet.Encode(this); stream.Write(data, 0, data.Length); return(data.Length); }
public int SendPacket(G2Packet packet) { Debug.Assert(Thread.CurrentThread.ManagedThreadId == XRay.CoreThread.ManagedThreadId, "Send packet called not on core thread"); if (State != TcpState.Connected) { return(0); } try { byte[] encoded = packet.Encode(Protocol); PacketLogEntry logEntry = new PacketLogEntry(DateTime.Now, DirectionType.Out, ToString(), encoded); LogPacket(logEntry); // fill up final buffer, keep encrypt buffer clear if (BUFF_SIZE - SendBuffSize < encoded.Length + 128) { throw new Exception("SendBuff Full"); } // encrypt encoded.CopyTo(SendBuffer, SendBuffSize); SendBuffSize += encoded.Length; OnlyFillerInSendBuffer = false; TrySend(); // record bandwidth return(encoded.Length); } catch (Exception ex) { Log("SendPacket", ex.Message); } return(0); }
public int WritePacket(G2Packet packet) { byte[] data = packet.Encode(Protocol); ParentStream.Write(data, 0, data.Length); return(data.Length); }
public int WritePacket(G2Packet packet) { byte[] data = packet.Encode(Protocol); ParentStream.Write(data, 0, data.Length); return data.Length; }
public int WriteToFile(G2Packet packet, Stream stream) { byte[] data = packet.Encode(this); stream.Write(data, 0, data.Length); return data.Length; }
public int SendPacket(G2Packet packet) { Debug.Assert(Thread.CurrentThread.ManagedThreadId == XRay.CoreThread.ManagedThreadId, "Send packet called not on core thread"); if (State != TcpState.Connected) return 0; try { byte[] encoded = packet.Encode(Protocol); PacketLogEntry logEntry = new PacketLogEntry(DateTime.Now, DirectionType.Out, ToString(), encoded); LogPacket(logEntry); // fill up final buffer, keep encrypt buffer clear if (BUFF_SIZE - SendBuffSize < encoded.Length + 128) throw new Exception("SendBuff Full"); // encrypt encoded.CopyTo(SendBuffer, SendBuffSize); SendBuffSize += encoded.Length; OnlyFillerInSendBuffer = false; TrySend(); // record bandwidth return encoded.Length; } catch (Exception ex) { Log("SendPacket", ex.Message); } return 0; }