Exemplo n.º 1
0
        /// <summary>
        /// Sends a message to this channel.
        /// </summary>
        /// <param name="sender">the chatter saying the message</param>
        public void SendMessage(IChatter sender, string message)
        {
            ChannelMember mi;

            if (!Members.TryGetValue(sender.EntityId.Low, out mi))
            {
                ChannelHandler.SendNotOnChannelReply(sender, m_name);
                return;
            }

            if (mi.IsMuted)
            {
                ChannelHandler.SendMutedReply(sender, m_name);
                return;
            }

            bool isMod = mi.IsModerator;

            if (IsModerated && !isMod)
            {
                ChannelHandler.SendNotOnChannelReply(sender, m_name);
                return;
            }

            if (sender is IUser)
            {
                if (RealmCommandHandler.HandleCommand((IUser)sender, message, this))
                {
                    return;
                }
            }
            ChannelHandler.SendPacketToChannel(this, ChatMgr.CreateNormalChatMessagePacket(sender.Name, message, Locale.En));

            /*using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
             * {
             *      packet.Write((byte)ChatMsgType.Channel);
             *      packet.Write((uint)sender.SpokenLanguage);
             *      packet.Write(sender.EntityId);
             *      packet.Write(0);			// unknown
             *      packet.WriteCString(Name);
             *      packet.Write(sender.EntityId);
             *      packet.WriteUIntPascalString(message);
             *      packet.Write((byte)sender.ChatTag); // chat tag
             *
             *      if (isMod)
             *      {
             *              ChannelHandler.SendPacketToChannel(this, packet);
             *      }
             *      else
             *      {
             *              ChannelHandler.SendPacketToChannel(this, packet, sender.EntityId);
             *      }
             *
             *      ChatMgr.ChatNotify(sender, message, sender.SpokenLanguage, ChatMsgType.Channel, this);
             * }*/
        }
Exemplo n.º 2
0
 public ChatChannel(ChatChannelGroup group, string name, ChatChannelFlags flags, bool constant)
     : this(group, name)
 {
     this.m_flagsEntry = new ChatChannelFlagsEntry()
     {
         Flags       = flags,
         ClientFlags = ChatMgr.Convert(flags)
     };
     this.IsConstant = constant;
 }
Exemplo n.º 3
0
        public bool SetBanned(ChannelMember member, string targetName, bool addBan)
        {
            IUser namedEntity = World.GetNamedEntity(targetName, true) as IUser;

            if (namedEntity != null)
            {
                return(this.SetBanned(member, namedEntity, false));
            }
            ChatMgr.SendChatPlayerNotFoundReply((IPacketReceiver)member.User, targetName);
            return(false);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">name of channel</param>
 public ChatChannel(ChatChannelGroup group, string name, ChatChannelFlags flags, bool constant, JoinValidationHandler joinValidator)
     : this(group, name)
 {
     m_flagsEntry = new ChatChannelFlagsEntry
     {
         Flags       = flags,
         ClientFlags = ChatMgr.Convert(flags)
     };
     m_joinValidator = joinValidator;
     IsConstant      = constant;
 }
Exemplo n.º 5
0
        public bool SetBanned(ChannelMember member, string targetName, bool addBan)
        {
            var target = World.GetNamedEntity(targetName, true) as IUser;

            if (target != null)
            {
                return(SetBanned(member, target, false));
            }

            ChatMgr.SendChatPlayerNotFoundReply(member.User, targetName);
            return(false);
        }
Exemplo n.º 6
0
        public void Invite(ChannelMember inviter, string targetName)
        {
            IUser namedEntity = World.GetNamedEntity(targetName, false) as IUser;

            if (namedEntity != null)
            {
                this.Invite(inviter, namedEntity);
            }
            else
            {
                ChatMgr.SendChatPlayerNotFoundReply((IPacketReceiver)inviter.User, targetName);
            }
        }
Exemplo n.º 7
0
        public void Invite(ChannelMember inviter, string targetName)
        {
            var target = World.GetNamedEntity(targetName, false) as IUser;

            if (target != null)
            {
                Invite(inviter, target);
            }
            else
            {
                ChatMgr.SendChatPlayerNotFoundReply(inviter.User, targetName);
            }
        }
Exemplo n.º 8
0
 public void Leave(Character leaver)
 {
     lock (this)
     {
         Members.Remove(leaver.AccId);
     }
     leaver.ChatRoom = null;
     ChatMgr.SendChatRoomEventResponse(this, ChatRoomEventType.Left, leaver);
     if (Owner == leaver && Members.Count > 0)
     {
         Owner = Members.Values.First();
         ChatMgr.SendChatRoomEventResponse(this, ChatRoomEventType.LeaderChanged, Owner);
         ChatMgr.SendChatRoomVisibleResponse(Owner, ChatRoomVisibilityStatus.Visible, this);
     }
     ChatMgr.SendChatRoomVisibleResponse(leaver, ChatRoomVisibilityStatus.Closed, null);
 }
Exemplo n.º 9
0
        public void SendMessage(string message)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
            {
                packet.Write((byte)17);
                packet.Write(7U);
                packet.Write((ulong)EntityId.Zero);
                packet.WriteCString("");
                packet.Write((ulong)EntityId.Zero);
                packet.WriteUIntPascalString(message);
                packet.Write((byte)0);
                ChannelHandler.SendPacketToChannel(this, packet);
            }

            ChatMgr.ChatNotify((IChatter)null, message, ChatLanguage.Common, ChatMsgType.Channel,
                               (IGenericChatTarget)this);
        }
Exemplo n.º 10
0
        public void Leave(Character leaver)
        {
            lock (this)
                this.Members.Remove(leaver.AccId);
            leaver.ChatRoom = (Asda2Chatroom)null;
            ChatMgr.SendChatRoomEventResponse(this, ChatRoomEventType.Left, leaver);
            if (this.Owner == leaver && this.Members.Count > 0)
            {
                this.Owner = this.Members.Values.First <Character>();
                ChatMgr.SendChatRoomEventResponse(this, ChatRoomEventType.LeaderChanged, this.Owner);
                ChatMgr.SendChatRoomVisibleResponse(this.Owner, ChatRoomVisibilityStatus.Visible, this,
                                                    (Character)null);
            }

            ChatMgr.SendChatRoomVisibleResponse(leaver, ChatRoomVisibilityStatus.Closed, (Asda2Chatroom)null,
                                                (Character)null);
        }
Exemplo n.º 11
0
        public void SendMessage(string message)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
            {
                packet.Write((byte)ChatMsgType.Channel);
                packet.Write((uint)ChatLanguage.Common);
                packet.Write(EntityId.Zero);
                packet.WriteCString("");
                packet.Write(EntityId.Zero);
                packet.WriteUIntPascalString(message);
                packet.Write((byte)ChatTag.None);                 // chat tag

                ChannelHandler.SendPacketToChannel(this, packet);
            }

            ChatMgr.ChatNotify(null, message, ChatLanguage.Common, ChatMsgType.Channel, this);
        }
Exemplo n.º 12
0
 public void TryJoin(Character joiner, string password)
 {
     if (MaxMembersCount <= Members.Count)
     {
         ChatMgr.SendEnterChatRoomResultResponse(joiner.Client, EnterChatRoomStatus.RoomisFull, null);
         return;
     }
     if (IsPrivate && password != Password)
     {
         ChatMgr.SendEnterChatRoomResultResponse(joiner.Client, EnterChatRoomStatus.WrongPassword, null);
         return;
     }
     lock (this)
     {
         Members.Add(joiner.AccId, joiner);
     }
     joiner.ChatRoom = this;
     ChatMgr.SendChatRoomEventResponse(this, ChatRoomEventType.Joined, joiner);
     ChatMgr.SendEnterChatRoomResultResponse(joiner.Client, EnterChatRoomStatus.Ok, this);
 }
Exemplo n.º 13
0
 public void TryJoin(Character joiner, string password)
 {
     if ((int)this.MaxMembersCount <= this.Members.Count)
     {
         ChatMgr.SendEnterChatRoomResultResponse(joiner.Client, EnterChatRoomStatus.RoomisFull,
                                                 (Asda2Chatroom)null);
     }
     else if (this.IsPrivate && password != this.Password)
     {
         ChatMgr.SendEnterChatRoomResultResponse(joiner.Client, EnterChatRoomStatus.WrongPassword,
                                                 (Asda2Chatroom)null);
     }
     else
     {
         lock (this)
             this.Members.Add(joiner.AccId, joiner);
         joiner.ChatRoom = this;
         ChatMgr.SendChatRoomEventResponse(this, ChatRoomEventType.Joined, joiner);
         ChatMgr.SendEnterChatRoomResultResponse(joiner.Client, EnterChatRoomStatus.Ok, this);
     }
 }
Exemplo n.º 14
0
 public void Dissmiss(Character dissmiser, uint targetAccId)
 {
     lock (this)
     {
         if (dissmiser != Owner || dissmiser.EntityId.Low == targetAccId)
         {
             dissmiser.SendInfoMsg("You are not chat room owner.");
             ChatMgr.SendDissmisedFromCharRoomResultResponse(dissmiser.Client, DissmissCharacterFromChatRoomResult.Fail);
         }
         if (!Members.ContainsKey(targetAccId))
         {
             dissmiser.SendInfoMsg("Target not founded.");
             ChatMgr.SendDissmisedFromCharRoomResultResponse(dissmiser.Client, DissmissCharacterFromChatRoomResult.Fail);
         }
         var target = Members[targetAccId];
         ChatMgr.SendChatRoomEventResponse(this, ChatRoomEventType.Banned, target);
         target.ChatRoom = null;
         Members.Remove(targetAccId);
         ChatMgr.SendChatRoomClosedResponse(target.Client, ChatRoomClosedStatus.Banned);
         ChatMgr.SendDissmisedFromCharRoomResultResponse(dissmiser.Client, DissmissCharacterFromChatRoomResult.Ok);
     }
 }
Exemplo n.º 15
0
 public void Invite(ChannelMember inviter, IUser target)
 {
     if (!target.IsIgnoring(inviter.User) || inviter.User.Role.IsStaff)
     {
         if (this.IsPresent(target.EntityId.Low))
         {
             ChannelHandler.SendAlreadyOnChannelReply((IPacketReceiver)inviter.User, target.Name,
                                                      target.EntityId);
         }
         else if (target.FactionGroup != inviter.User.FactionGroup)
         {
             ChannelHandler.SendWrongFaction((IPacketReceiver)inviter.User, this.m_name, target.Name);
         }
         else
         {
             ChannelHandler.SendInvitedMessage((IPacketReceiver)target, this.m_name, inviter.User.EntityId);
             ChannelHandler.SendYouInvitedReply((IPacketReceiver)inviter.User, this.m_name, target.Name);
         }
     }
     else
     {
         ChatMgr.SendChatPlayerNotFoundReply((IPacketReceiver)inviter.User, target.Name);
     }
 }
Exemplo n.º 16
0
 public void Invite(ChannelMember inviter, IUser target)
 {
     if (!target.IsIgnoring(inviter.User) || inviter.User.Role.IsStaff)
     {
         if (IsPresent(target.EntityId.Low))
         {
             ChannelHandler.SendAlreadyOnChannelReply(inviter.User, target.Name, target.EntityId);
         }
         else if (target.FactionGroup != inviter.User.FactionGroup)
         {
             ChannelHandler.SendWrongFaction(inviter.User, m_name, target.Name);
         }
         else
         {
             // TODO: all other checks (eg ban etc)
             ChannelHandler.SendInvitedMessage(target, m_name, inviter.User.EntityId);
             ChannelHandler.SendYouInvitedReply(inviter.User, m_name, target.Name);
         }
     }
     else
     {
         ChatMgr.SendChatPlayerNotFoundReply(inviter.User, target.Name);
     }
 }