public void MyOnPublicSpeach(PublicSpeech aPublicSpeech) { AddLog(LogType.NetworkProtocol, "Someone said something - {0} : {1}", aPublicSpeech.Name, aPublicSpeech.Message); }
private void AnalyzePacket(byte[] aBuffer, PacketDirection aType) { switch (aType) { case PacketDirection.ClientToServer: break; // maybe later case PacketDirection.ServerToClient: // TODO : Here should be different types of mu protocol packets with parsing and event-based processing CommonServerToClientPacket cstcpTemp = new CommonServerToClientPacket(aBuffer); switch (cstcpTemp.ClassType) { case PacketClass.C1: switch (cstcpTemp.MesTypeC1) { case MessageTypeC1.PublicSpeech: if (OnPublicSpeach != null) { using ( PublicSpeech pspTemp = new PublicSpeech(aBuffer) ) AsyncHelper.FireAndForget(OnPublicSpeach, pspTemp); } break; case MessageTypeC1.CharacterList: if (OnCharacterList != null) { using ( CharacterList clTemp = new CharacterList(aBuffer) ) AsyncHelper.FireAndForget(OnCharacterList, clTemp); } break; case MessageTypeC1.DamageReceived: if (OnDamageReceived != null) { using ( DamageReceived drTemp = new DamageReceived(aBuffer) ) AsyncHelper.FireAndForget(OnDamageReceived, drTemp); } break; case MessageTypeC1.Death: if (OnDeath != null) { using ( Death dTemp = new Death(aBuffer) ) AsyncHelper.FireAndForget(OnDeath, dTemp); } break; case MessageTypeC1.OpenCreateGuildWindow: if (OnOpenCreateGuildWindow != null) AsyncHelper.FireAndForget(OnOpenCreateGuildWindow); break; case MessageTypeC1.OpenVaultWindow: if (OnOpenVaultWindow != null) AsyncHelper.FireAndForget(OnOpenVaultWindow); break; case MessageTypeC1.PlayerPosition: if (OnLivingPosition != null) { using ( LivingPosition ppTemp = new LivingPosition(aBuffer) ) AsyncHelper.FireAndForget(OnLivingPosition, ppTemp); } break; case MessageTypeC1.PutItem: if (OnPutItem != null) { using ( PutItem piTemp = new PutItem(aBuffer) ) AsyncHelper.FireAndForget(OnPutItem, piTemp); } break; case MessageTypeC1.ServerText: if (OnServerText != null) { using ( ServerText stTemp = new ServerText(aBuffer) ) AsyncHelper.FireAndForget(OnServerText, stTemp); } break; case MessageTypeC1.TraiderInfo: if (OnTraiderInfo != null) { using ( TraiderInfo tiTemp = new TraiderInfo(aBuffer) ) AsyncHelper.FireAndForget(OnTraiderInfo, tiTemp); } break; case MessageTypeC1.StopMoving: if (OnStopMoving != null) { using ( StopMoving smTemp = new StopMoving(aBuffer) ) AsyncHelper.FireAndForget(OnStopMoving, smTemp); } break; case MessageTypeC1.GameServerAnswer: if (OnGameServerAnswer != null) { using ( GameServerAnswer gsaTemp = new GameServerAnswer(aBuffer) ) AsyncHelper.FireAndForget(OnGameServerAnswer, gsaTemp); } break; case MessageTypeC1.UpdateHealth: if (OnUpdateHealth != null) { using ( UpdateHealth uhTemp = new UpdateHealth(aBuffer) ) AsyncHelper.FireAndForget(OnUpdateHealth, uhTemp); } break; case MessageTypeC1.UpdateMana: if (OnUpdateMana != null) { using ( UpdateMana umTemp = new UpdateMana(aBuffer) ) AsyncHelper.FireAndForget(OnUpdateMana, umTemp); } break; } break; } if ((cstcpTemp.ClassType != PacketClass.Unknown) && (cstcpTemp.Length < aBuffer.Length)) { byte[] subArray = new byte[aBuffer.Length - cstcpTemp.Length]; Array.Copy(aBuffer, cstcpTemp.Length, subArray, 0, aBuffer.Length - cstcpTemp.Length); AnalyzePacket(subArray, aType); } break; } }