public override async void Execute(Level level) { try { ClientAvatar player = level.GetPlayerAvatar(); TroopRequestStreamEntry cm = new TroopRequestStreamEntry(); Alliance all = await ObjectManager.GetAlliance(player.GetAllianceId()); cm.SetId(all.GetChatMessages().Count + 1); cm.SetSenderId(player.GetId()); cm.SetHomeId(player.GetId()); cm.SetSenderLeagueId(player.GetLeagueId()); cm.SetSenderName(player.GetAvatarName()); cm.SetSenderRole(await player.GetAllianceRole()); cm.SetMessage(Message); cm.SetMaxTroop(player.GetAllianceCastleTotalCapacity()); all.AddChatMessage(cm); StreamEntry s = all.GetChatMessages().Find(c => c.GetSenderId() == level.GetPlayerAvatar().GetId() && c.GetStreamEntryType() == 1); if (s == null) { all.GetChatMessages().RemoveAll(t => t == s); } all.AddChatMessage(cm); foreach (AllianceMemberEntry op in all.GetAllianceMembers()) { Level aplayer = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (aplayer.GetClient() != null) { if (s != null) { PacketProcessor.Send(new AllianceStreamEntryRemovedMessage(aplayer.GetClient(), s.GetId())); } AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(aplayer.GetClient()); p.SetStreamEntry(cm); PacketProcessor.Send(p); } } } catch (Exception) { ResourcesManager.DropClient(level.GetClient().GetSocketHandle()); } }
internal override async void Process() { try { ClientAvatar player = this.Device.Player.Avatar; player.TroopRequestMessage = this.Message; Alliance all = ObjectManager.GetAlliance(player.AllianceId); TroopRequestStreamEntry cm = new TroopRequestStreamEntry(); cm.SetSender(player); cm.Message = this.Message; cm.ID = all.m_vChatMessages.Count + 1; cm.SetMaxTroop(player.GetAllianceCastleTotalCapacity()); cm.m_vDonatedTroop = player.GetAllianceCastleUsedCapacity(); StreamEntry s = all.m_vChatMessages.Find(c => c.SenderID == this.Device.Player.Avatar.UserId && c.GetStreamEntryType() == 1); if (s != null) { all.m_vChatMessages.RemoveAll(t => t == s); all.AddChatMessage(cm); } else { all.AddChatMessage(cm); } foreach (AllianceMemberEntry op in all.GetAllianceMembers()) { Level aplayer = await ResourcesManager.GetPlayer(op.AvatarId); if (aplayer.Client != null) { new AllianceStreamEntryMessage(aplayer.Client) { StreamEntry = cm }.Send(); if (s != null) { new AllianceStreamEntryRemovedMessage(aplayer.Client, s.ID).Send(); } } } } catch (Exception) { } }