public async Task SpreadBroadcastpacket(BroadcastPacket sentPacket)
        {
            if (sentPacket != null)
            {
                switch (sentPacket.Receiver)
                {
                case ReceiverType.All:     // send packet to everyone
                    foreach (ClientSession session in Sessions)
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.AllExceptMe:     // send to everyone except the sender
                    foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.OnlySomeone:
                {
                    if (sentPacket.SomeonesCharacterId > 0 || !String.IsNullOrEmpty(sentPacket.SomeonesCharacterName))
                    {
                        ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName);

                        if (targetSession != null)
                        {
                            targetSession.SendPacket(sentPacket.Packet);
                        }
                    }

                    break;
                }

                case ReceiverType.AllNoEmoBlocked:
                    foreach (ClientSession session in Sessions.Where(s => !s.Character.EmoticonsBlocked))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.AllNoHeroBlocked:
                    foreach (ClientSession session in Sessions.Where(s => !s.Character.HeroChatBlocked))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.Group:
                    foreach (ClientSession session in Sessions.Where(s => s.Character.Group != null &&
                                                                     s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;
                }
            }
        }
Beispiel #2
0
 public void Broadcast(BroadcastPacket packet)
 {
     try
     {
         spreadBroadcastpacket(packet);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
 public void Broadcast(BroadcastPacket packet, int delay = 0)
 {
     // Send message to all online users
     Task.Factory.StartNew(
         async() =>
     {
         await Task.Delay(delay);
         try
         {
             await SpreadBroadcastpacket(packet);
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
     });
 }
Beispiel #4
0
        private void spreadBroadcastpacket(BroadcastPacket sentPacket)
        {
            if (Sessions != null && !string.IsNullOrEmpty(sentPacket?.Packet))
            {
                switch (sentPacket.Receiver)
                {
                case ReceiverType.All:     // send packet to everyone
                    if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture))
                    {
                        foreach (ClientSession session in Sessions)
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    else
                    {
                        Parallel.ForEach(Sessions, session =>
                        {
                            if (session?.HasSelectedCharacter == true)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        });
                    }
                    break;

                case ReceiverType.AllExceptMe:     // send to everyone except the sender
                    if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture))
                    {
                        foreach (ClientSession session in Sessions.Where(s => s?.SessionId != sentPacket.Sender?.SessionId))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    else
                    {
                        Parallel.ForEach(Sessions.Where(s => s?.SessionId != sentPacket.Sender?.SessionId), session =>
                        {
                            if (session?.HasSelectedCharacter == true)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        });
                    }
                    break;

                case ReceiverType.AllExceptGroup:
                    if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture))
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId && (s.Character?.Group == null || (s.Character?.Group?.GroupId != sentPacket.Sender?.Character?.Group?.GroupId))))
                        {
                            if (session.HasSelectedCharacter && !sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.AllExceptMeAct4:     // send to everyone except the sender(Act4)
                    Parallel.ForEach(Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId), session =>
                    {
                        if (session?.HasSelectedCharacter == true)
                        {
                            if (sentPacket.Sender != null)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                {
                                    if (session.Character.Faction == sentPacket.Sender.Character.Faction)
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                    else
                                    {
//TODO: Scrambled Packet for Act4
                                    }
                                }
                            }
                            else
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    });
                    break;

                case ReceiverType.AllInRange:     // send to everyone which is in a range of 50x50
                    if (sentPacket.XCoordinate != 0 && sentPacket.YCoordinate != 0)
                    {
                        Parallel.ForEach(Sessions.Where(s => s?.Character.IsInRange(sentPacket.XCoordinate, sentPacket.YCoordinate) == true), session =>
                        {
                            if (session?.HasSelectedCharacter == true)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        });
                    }
                    break;

                case ReceiverType.OnlySomeone:
                    if (sentPacket.SomeonesCharacterId > 0 || !string.IsNullOrEmpty(sentPacket.SomeonesCharacterName))
                    {
                        ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName);
                        if (targetSession?.HasSelectedCharacter == true)
                        {
                            if (sentPacket.Sender != null)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(targetSession.Character.CharacterId))
                                {
                                    targetSession.SendPacket(sentPacket.Packet);
                                }
                                else
                                {
                                    sentPacket.Sender.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                                }
                            }
                            else
                            {
                                targetSession.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.AllNoEmoBlocked:
                    Parallel.ForEach(Sessions.Where(s => s?.Character.EmoticonsBlocked == false), session =>
                    {
                        if (session?.HasSelectedCharacter == true && sentPacket.Sender?.Character.IsBlockedByCharacter(session.Character.CharacterId) == false)
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                    });
                    break;

                case ReceiverType.AllNoHeroBlocked:
                    Parallel.ForEach(Sessions.Where(s => s?.Character.HeroChatBlocked == false), session =>
                    {
                        if (session?.HasSelectedCharacter == true && sentPacket.Sender?.Character.IsBlockedByCharacter(session.Character.CharacterId) == false)
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                    });
                    break;

                case ReceiverType.Group:
                    foreach (ClientSession session in Sessions.Where(s => s.Character?.Group != null && sentPacket.Sender?.Character?.Group != null && s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.Unknown:
                    break;
                }
            }
        }
        public void SpreadBroadcastpacket(BroadcastPacket sentPacket)
        {
            if (Sessions != null && !string.IsNullOrEmpty(sentPacket?.Packet))
            {
                switch (sentPacket.Receiver)
                {
                case ReceiverType.All:     // send packet to everyone
                    foreach (ClientSession session in Sessions)
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.AllExceptMe:     // send to everyone except the sender
                    foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.AllInRange:     // send to everyone which is in a range of 50x50
                    if (sentPacket.XCoordinate != 0 && sentPacket.YCoordinate != 0)
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.Character.IsInRange(sentPacket.XCoordinate, sentPacket.YCoordinate)))
                        {
                            session.SendPacket(sentPacket.Packet, 1);
                        }
                    }
                    break;

                case ReceiverType.OnlySomeone:
                {
                    if (sentPacket.SomeonesCharacterId > 0 || !string.IsNullOrEmpty(sentPacket.SomeonesCharacterName))
                    {
                        ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName);

                        targetSession?.SendPacket(sentPacket.Packet);
                    }

                    break;
                }

                case ReceiverType.AllNoEmoBlocked:
                    foreach (ClientSession session in Sessions.Where(s => !s.Character.EmoticonsBlocked))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.AllNoHeroBlocked:
                    foreach (ClientSession session in Sessions.Where(s => !s.Character.HeroChatBlocked))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.Group:
                    foreach (ClientSession session in Sessions.Where(s => s.Character?.Group != null && sentPacket.Sender?.Character?.Group != null && s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;
                }
            }
        }
Beispiel #6
0
        private void SpreadBroadcastpacket(BroadcastPacket sentPacket)
        {
            if (Sessions != null && !string.IsNullOrEmpty(sentPacket?.Packet))
            {
                switch (sentPacket.Receiver)
                {
                case ReceiverType.All:     // send packet to everyone
                    foreach (ClientSession session in Sessions)
                    {
                        if (session.HasSelectedCharacter)
                        {
                            if (sentPacket.Sender != null)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                            else
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.AllExceptMe:     // send to everyone except the sender
                    foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId))
                    {
                        if (session.HasSelectedCharacter)
                        {
                            if (sentPacket.Sender != null)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                            else
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.AllInRange:     // send to everyone which is in a range of 50x50
                    if (sentPacket.XCoordinate != 0 && sentPacket.YCoordinate != 0)
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.Character.IsInRange(sentPacket.XCoordinate, sentPacket.YCoordinate)))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    break;

                case ReceiverType.OnlySomeone:
                    if (sentPacket.SomeonesCharacterId > 0 || !string.IsNullOrEmpty(sentPacket.SomeonesCharacterName))
                    {
                        ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName);
                        if (targetSession != null && targetSession.HasSelectedCharacter)
                        {
                            if (sentPacket.Sender != null)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(targetSession.Character.CharacterId))
                                {
                                    targetSession.SendPacket(sentPacket.Packet);
                                }
                                else
                                {
                                    sentPacket.Sender.SendPacket(sentPacket.Sender.Character.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                                }
                            }
                            else
                            {
                                targetSession.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;


                case ReceiverType.AllNoEmoBlocked:
                    foreach (ClientSession session in Sessions.Where(s => !s.Character.EmoticonsBlocked))
                    {
                        if (session.HasSelectedCharacter)
                        {
                            if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.AllNoHeroBlocked:
                    foreach (ClientSession session in Sessions.Where(s => !s.Character.HeroChatBlocked))
                    {
                        if (session.HasSelectedCharacter)
                        {
                            if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.Group:
                    foreach (ClientSession session in Sessions.Where(s => s.Character?.Group != null && sentPacket.Sender?.Character?.Group != null && s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.Unknown:
                    break;
                }
            }
        }
Beispiel #7
0
        public void SpreadBroadcastpacket(BroadcastPacket sentPacket)
        {
            if (Sessions != null && sentPacket != null && !String.IsNullOrEmpty(sentPacket.Packet))
            {
                switch (sentPacket.Receiver)
                {
                    case ReceiverType.All: // send packet to everyone
                        foreach (ClientSession session in Sessions)
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                        break;

                    case ReceiverType.AllExceptMe: // send to everyone except the sender
                        foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId))
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                        break;

                    case ReceiverType.AllInRange: // send to everyone which is in a range of 50x50
                        if (sentPacket.XCoordinate != 0 && sentPacket.YCoordinate != 0)
                        {
                            foreach (ClientSession session in Sessions.Where(s => s.Character.IsInRange(sentPacket.XCoordinate, sentPacket.YCoordinate)))
                            {
                                session.SendPacket(sentPacket.Packet, 1);
                            }
                        }
                        break;

                    case ReceiverType.OnlySomeone:
                        {
                            if (sentPacket.SomeonesCharacterId > 0 || !String.IsNullOrEmpty(sentPacket.SomeonesCharacterName))
                            {
                                ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName);

                                if (targetSession != null)
                                {
                                    targetSession.SendPacket(sentPacket.Packet);
                                }
                            }

                            break;
                        }
                    case ReceiverType.AllNoEmoBlocked:
                        foreach (ClientSession session in Sessions.Where(s => !s.Character.EmoticonsBlocked))
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                        break;

                    case ReceiverType.AllNoHeroBlocked:
                        foreach (ClientSession session in Sessions.Where(s => !s.Character.HeroChatBlocked))
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                        break;

                    case ReceiverType.Group:
                        foreach (ClientSession session in Sessions.Where(s => s.Character != null && s.Character.Group != null
                                 && sentPacket.Sender != null && sentPacket.Sender.Character != null && sentPacket.Sender.Character.Group != null
                                 && s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId))
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                        break;
                }
            }
        }
Beispiel #8
0
 public void Broadcast(BroadcastPacket packet)
 {
     try
     {
         SpreadBroadcastpacket(packet);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
Beispiel #9
0
        private void spreadBroadcastpacket(BroadcastPacket sentPacket)
        {
            if (Sessions != null && !string.IsNullOrEmpty(sentPacket?.Packet))
            {
                switch (sentPacket.Receiver)
                {
                case ReceiverType.All:     // send packet to everyone
                    if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture))
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.Character == null || !s.Character.IsChangingMapInstance))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    else
                    {
                        Parallel.ForEach(Sessions, session =>
                        {
                            if (session?.HasSelectedCharacter == true)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId) || sentPacket.Packet.StartsWith("revive", StringComparison.CurrentCulture))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        });
                    }
                    break;

                case ReceiverType.AllExceptMe:     // send to everyone except the sender
                    if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture))
                    {
                        foreach (ClientSession session in Sessions.Where(s => s?.SessionId != sentPacket.Sender?.SessionId && (s.Character == null || !s.Character.IsChangingMapInstance)))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    //if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    else
                    {
                        Parallel.ForEach(Sessions.Where(s => s?.SessionId != sentPacket.Sender?.SessionId), session =>
                        {
                            if (session?.HasSelectedCharacter == true)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        });
                    }
                    break;

                case ReceiverType.AllExceptGroup:
                    if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture))
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId && (s.Character == null || !s.Character.IsChangingMapInstance)))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId && (s.Character?.Group == null || (s.Character?.Group?.GroupId != sentPacket.Sender?.Character?.Group?.GroupId))))
                        {
                            if (session.HasSelectedCharacter && !sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.AllExceptMeAct4:     // send to everyone except the sender(Act4)
                    Parallel.ForEach(Sessions.Where(s => s.SessionId != sentPacket.Sender?.SessionId && (s.Character == null || !s.Character.IsChangingMapInstance)), session =>
                    {
                        if (session?.HasSelectedCharacter == true)
                        {
                            if (sentPacket.Sender != null)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                {
                                    if (session.Character.Faction == sentPacket.Sender.Character.Faction)
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                    else if (session.Account.Authority >= AuthorityType.TrialModerator /*|| session.Account.Authority == AuthorityType.Moderator*/)
                                    {
                                        string[] vals = sentPacket.Packet.Split(' ');
                                        if (vals[0] == "say" && vals[3] == "13")
                                        {
                                            vals[5]           = $"[{sentPacket.Sender.Character.Faction}] {vals[5]}";
                                            sentPacket.Packet = string.Join(" ", vals);
                                        }
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                            }
                            else
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    });
                    break;

                case ReceiverType.AllInRange:     // send to everyone which is in a range of 50x50
                    if (sentPacket.XCoordinate != 0 && sentPacket.YCoordinate != 0)
                    {
                        Parallel.ForEach(Sessions.Where(s => s?.Character.IsInRange(sentPacket.XCoordinate, sentPacket.YCoordinate) == true && (s.Character == null || !s.Character.IsChangingMapInstance)), session =>
                        {
                            if (session?.HasSelectedCharacter == true)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        });
                    }
                    break;

                case ReceiverType.OnlySomeone:
                    if (sentPacket.SomeonesCharacterId > 0 || !string.IsNullOrEmpty(sentPacket.SomeonesCharacterName))
                    {
                        ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName);
                        if (targetSession?.HasSelectedCharacter == true)
                        {
                            if (sentPacket.Sender != null)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(targetSession.Character.CharacterId))
                                {
                                    targetSession.SendPacket(sentPacket.Packet);
                                }
                                else
                                {
                                    sentPacket.Sender.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                                }
                            }
                            else
                            {
                                targetSession.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.AllNoEmoBlocked:
                    Parallel.ForEach(Sessions.Where(s => s?.Character.EmoticonsBlocked == false), session =>
                    {
                        if (session?.HasSelectedCharacter == true && sentPacket.Sender?.Character.IsBlockedByCharacter(session.Character.CharacterId) == false)
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                    });
                    break;

                case ReceiverType.AllNoHeroBlocked:
                    Parallel.ForEach(Sessions.Where(s => s?.Character.HeroChatBlocked == false), session =>
                    {
                        if (session?.HasSelectedCharacter == true && sentPacket.Sender?.Character.IsBlockedByCharacter(session.Character.CharacterId) == false)
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                    });
                    break;

                case ReceiverType.Group:
                    foreach (ClientSession session in Sessions.Where(s => s.Character?.Group != null && sentPacket.Sender?.Character?.Group != null && s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.Unknown:
                    break;
                }
            }
        }