public Messaging() { this.m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this.m_receiveBuffer = new SocketBuffer(2048); this.m_messageFactory = LogicMagicMessageFactory.Instance; this.m_receiveQueue = new ConcurrentQueue <PiranhaMessage>(); this.m_sendQueue = new ConcurrentQueue <PiranhaMessage>(); this.m_scramblerSeed = Environment.TickCount; this.InitEncrypters(); }
public void Decode(ByteStream stream, LogicMessageFactory factory) { this.m_messageId = stream.ReadByte(); int messageType = stream.ReadVInt(); this.m_piranhaMessage = factory.CreateMessageByType(messageType); if (this.m_piranhaMessage != null) { int encodingLength = stream.ReadVInt(); this.m_piranhaMessage.GetByteStream().SetByteArray(stream.ReadBytes(encodingLength, 900000), encodingLength); } else { Debugger.Warning("UdpMessage::decode unable to read message type " + messageType); } }
public void Decode(byte[] buffer, int length, LogicMessageFactory factory) { ByteStream stream = new ByteStream(buffer, length); if (!stream.IsAtEnd()) { this.m_ackMessageIdCount = stream.ReadVInt(); if (this.m_ackMessageIdCount <= 1400) { this.m_ackMessageIds = stream.ReadBytes(this.m_ackMessageIdCount, 1400); if (!stream.IsAtEnd()) { int messageCount = stream.ReadVInt(); if (messageCount <= 1400) { this.m_messages.EnsureCapacity(messageCount); for (int i = 0; i < messageCount; i++) { UdpMessage message = new UdpMessage(); message.Decode(stream, factory); if (message.GetPiranhaMessage() == null) { break; } this.m_messages.Add(message); } } } } } stream.Destruct(); }
static LogicMagicMessageFactory() { LogicMagicMessageFactory.Instance = new LogicMagicMessageFactory(); }
public Messaging(ClientConnection clientConnection) { this.m_clientConnection = clientConnection; this.m_messageFactory = LogicMagicMessageFactory.Instance; this.m_pepperState = PepperState.DEFAULT; }