/// <summary> /// Handle a message from the recv messagebuffer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void OnSendReaderProcessMessage(object sender, MessageBufferEventArgs e) { if (e.Length > GameMessage.HEADERLENGTH) { try { // set the direction as outgoing e.Direction = MessageDirection.ClientToServer; // parse the message GameMessage typedMessage = ExtractMessage(e); typedMessage.EncryptedPI = typedMessage.PI; typedMessage.MemoryStartAddress = e.MemoryAddress; CheckServerSave(typedMessage); // Advance the hashtable if encryption is enabled (3. TX packet) and if it's not a blacklisted packet if (CRCCreatorEnabled && advanceHashTable && ((MessageTypeGameMode)typedMessage.PI != MessageTypeGameMode.Blacklisted)) { CRCCreator.AdvanceHashTable(); } OnNewMessageAvailable(new GameMessageEventArgs(typedMessage)); } catch (Exception Error) { byte[] dump = new byte[e.Length]; Array.Copy(e.MessageBuffer, 0, dump, 0, e.Length); OnHandlerError(new HandlerErrorEventArgs(dump, Error.Message)); } } else { OnEmptyPacketFound(new EmptyMessageFoundEventArgs()); } }
/// <summary> /// Resets the PacketController to initial state /// </summary> public virtual void Reset() { CurrentServerSave = 0x00; LastServerSave = 0x00; PIDecoder = new PIDecoder(stringResources); CRCCreator = new CRCCreator(); CRCCreatorEnabled = false; Mode = ProtocolMode.Login; }