Esempio 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 channelMember;

            if (!this.Members.TryGetValue(sender.EntityId.Low, out channelMember))
            {
                ChannelHandler.SendNotOnChannelReply((IPacketReceiver)sender, this.m_name);
            }
            else if (channelMember.IsMuted)
            {
                ChannelHandler.SendMutedReply((IPacketReceiver)sender, this.m_name);
            }
            else if (this.IsModerated && !channelMember.IsModerator)
            {
                ChannelHandler.SendNotOnChannelReply((IPacketReceiver)sender, this.m_name);
            }
            else
            {
                if (sender is IUser &&
                    RealmCommandHandler.HandleCommand((IUser)sender, message, (IGenericChatTarget)this))
                {
                    return;
                }
                ChannelHandler.SendPacketToChannel(this,
                                                   ChatMgr.CreateNormalChatMessagePacket(sender.Name, message, Locale.Start, (Character)null));
            }
        }
Esempio n. 2
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);
             * }*/
        }