Exemplo n.º 1
0
 public ChatEvent(OSChatMessage msg, long time) : base(time)
 {
     sender  = msg.SenderUUID;
     channel = msg.Channel;
     msgType = msg.Type;
     message = msg.Message;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Try to send a message to the given presence
        /// </summary>
        /// <param name="presence">The receiver</param>
        /// <param name="fromPos"></param>
        /// <param name="regionPos">/param>
        /// <param name="fromAgentID"></param>
        /// <param name='ownerID'>
        /// Owner of the message.  For at least some messages from objects, this has to be correctly filled with the owner's UUID.
        /// This is the case for script error messages in viewer 3 since LLViewer change EXT-7762
        /// </param>
        /// <param name="fromName"></param>
        /// <param name="type"></param>
        /// <param name="message"></param>
        /// <param name="src"></param>
        /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a
        /// precondition</returns>
        protected virtual bool TrySendChatMessage(
            ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
            UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type,
            string message, ChatSourceType src, bool ignoreDistance)
        {
            if (presence.LifecycleState != ScenePresenceState.Running)
                return false;

            if (!ignoreDistance)
            {
                Vector3 fromRegionPos = fromPos + regionPos;
                Vector3 toRegionPos = presence.AbsolutePosition +
                    new Vector3(presence.Scene.RegionInfo.WorldLocX, presence.Scene.RegionInfo.WorldLocY, 0);

                int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);

                if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                    type == ChatTypeEnum.Say && dis > m_saydistance ||
                    type == ChatTypeEnum.Shout && dis > m_shoutdistance)
                {
                    return false;
                }
            }

            // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
            presence.ControllingClient.SendChatMessage(
                message, (byte) type, fromPos, fromName,
                fromAgentID, ownerID, (byte)src, (byte)ChatAudibleLevel.Fully);

            return true;
        }
Exemplo n.º 3
0
        public virtual void OnChatBroadcast(Object sender, OSChatMessage c)
        {
            if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return;

            ChatTypeEnum cType = c.Type;
            if (c.Channel == DEBUG_CHANNEL)
                cType = ChatTypeEnum.DebugChannel;

            if (cType == ChatTypeEnum.Region)
                cType = ChatTypeEnum.Say;

            if (c.Message.Length > 1100)
                c.Message = c.Message.Substring(0, 1000);

            // broadcast chat works by redistributing every incoming chat
            // message to each avatar in the scene.
            string fromName = c.From;

            UUID fromID = UUID.Zero;
            UUID ownerID = UUID.Zero;
            ChatSourceType sourceType = ChatSourceType.Object;
            if (null != c.Sender)
            {
                ScenePresence avatar = (c.Scene as Scene).GetScenePresence(c.Sender.AgentId);
                fromID = c.Sender.AgentId;
                fromName = avatar.Name;
                ownerID = c.Sender.AgentId;
                sourceType = ChatSourceType.Agent;
            }
            else if (c.SenderUUID != UUID.Zero)
            {
                fromID = c.SenderUUID;
                ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
            }

            // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
            HashSet<UUID> receiverIDs = new HashSet<UUID>();

            if (c.Scene != null)
            {
                ((Scene)c.Scene).ForEachRootClient
                (
                    delegate(IClientAPI client)
                    {
                        // don't forward SayOwner chat from objects to
                        // non-owner agents
                        if ((c.Type == ChatTypeEnum.Owner) &&
                            (null != c.SenderObject) &&
                            (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
                            return;

                        client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID,
                                               (byte)sourceType, (byte)ChatAudibleLevel.Fully);
                        receiverIDs.Add(client.AgentId);
                    }
                );
                (c.Scene as Scene).EventManager.TriggerOnChatToClients(
                    fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
             }
        }
Exemplo n.º 4
0
        public virtual void TrySendChatMessage(IScenePresence presence, Vector3 fromPos, Vector3 regionPos,
                                               UUID fromAgentID, string fromName, ChatTypeEnum type,
                                               string message, ChatSourceType src, float Range)
        {
            if (type == ChatTypeEnum.Custom)
            {
                Vector3 fromRegionPos = fromPos + regionPos;
                Vector3 toRegionPos   = presence.AbsolutePosition +
                                        new Vector3(presence.Scene.RegionInfo.RegionLocX,
                                                    presence.Scene.RegionInfo.RegionLocY, 0);

                int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);
                //Set the best fitting setting for custom
                if (dis < m_whisperdistance)
                {
                    type = ChatTypeEnum.Whisper;
                }
                else if (dis > m_saydistance)
                {
                    type = ChatTypeEnum.Shout;
                }
                else if (dis > m_whisperdistance && dis < m_saydistance)
                {
                    type = ChatTypeEnum.Say;
                }
            }

            // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
            presence.ControllingClient.SendChatMessage(message, (byte)type, fromPos, fromName,
                                                       fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Sends a chat message to clients in the region
        /// </summary>
        /// <param name="message">The message to send to users</param>
        /// <param name="type">The type of message (say, shout, whisper, owner say, etc)</param>
        /// <param name="channel">The channel to speak the message on</param>
        /// <param name="fromPos">The position of the speaker (the SceneObjectPart or ScenePresence)</param>
        /// <param name="fromName">The name of the speaker (the SceneObjectPart or ScenePresence)</param>
        /// <param name="fromID">The UUID of the speaker (the SceneObjectPart or ScenePresence)</param>
        /// <param name="destID">The user or object that is being spoken to (UUID.Zero specifies all users will get the message)</param>
        /// <param name="generatingAvatarID">The avatar ID that has generated this message regardless of
        /// if it is a script owned by this avatar, or the avatar itself</param>
        /// <param name="broadcast">Whether the message will be sent regardless of distance from the sender</param>
        public void SimChat(string message, ChatTypeEnum type, int channel, Vector3 fromPos,
                            string fromName, UUID fromID, UUID destID, UUID generatingAvatarID, bool broadcast)
        {
            OSChatMessage args = new OSChatMessage()
            {
                Channel            = channel,
                DestinationUUID    = destID,
                From               = fromName,
                GeneratingAvatarID = generatingAvatarID,
                Message            = message,
                Position           = fromPos,
                Scene              = this,
                SenderUUID         = fromID,
                Type               = type
            };

            if (broadcast)
            {
                EventManager.TriggerOnChatBroadcast(this, args);
            }
            else
            {
                EventManager.TriggerOnChatFromWorld(this, args);
            }
        }
Exemplo n.º 6
0
        protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                               UUID fromID, bool fromAgent, bool broadcast)
        {
            OSChatMessage args = new OSChatMessage();

            args.Message = Utils.BytesToString(message);
            args.Channel = channel;
            args.Type = type;
            args.Position = fromPos;
            args.SenderUUID = fromID;
            args.Scene = this;

            if (fromAgent)
            {
                ScenePresence user = GetScenePresence(fromID);
                if (user != null)
                    args.Sender = user.ControllingClient;
            }
            else
            {
                SceneObjectPart obj = GetSceneObjectPart(fromID);
                args.SenderObject = obj;
            }

            args.From = fromName;
            //args.

            if (broadcast)
                EventManager.TriggerOnChatBroadcast(this, args);
            else
                EventManager.TriggerOnChatFromWorld(this, args);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Try to send a message to the given presence
        /// </summary>
        /// <param name="presence">The receiver</param>
        /// <param name="fromPos"></param>
        /// <param name="regionPos">/param>
        /// <param name="fromAgentID"></param>
        /// <param name="fromName"></param>
        /// <param name="type"></param>
        /// <param name="message"></param>
        /// <param name="src"></param>
        /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a
        /// precondition</returns>
        protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
                                                  UUID fromAgentID, string fromName, ChatTypeEnum type,
                                                  string message, ChatSourceType src, bool ignoreDistance)
        {
            // don't send stuff to child agents
            if (presence.IsChildAgent)
            {
                return(false);
            }

            Vector3 fromRegionPos = fromPos + regionPos;
            Vector3 toRegionPos   = presence.AbsolutePosition +
                                    new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
                                                presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

            int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);

            if (!ignoreDistance)
            {
                if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                    type == ChatTypeEnum.Say && dis > m_saydistance ||
                    type == ChatTypeEnum.Shout && dis > m_shoutdistance)
                {
                    return(false);
                }
            }

            // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
            presence.ControllingClient.SendChatMessage(message, (byte)type, fromPos, fromName,
                                                       fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully);

            return(true);
        }
Exemplo n.º 8
0
        public virtual void TrySendChatMessage(IScenePresence presence, Vector3 fromPos,
                                               UUID fromAgentID, string fromName, ChatTypeEnum type,
                                               string message, ChatSourceType src, float Range)
        {
            if (type == ChatTypeEnum.Custom)
            {
                int dis = (int)Util.GetDistanceTo(fromPos, presence.AbsolutePosition);
                //Set the best fitting setting for custom
                if (dis < m_whisperdistance)
                {
                    type = ChatTypeEnum.Whisper;
                }
                else if (dis > m_saydistance)
                {
                    type = ChatTypeEnum.Shout;
                }
                else if (dis > m_whisperdistance && dis < m_saydistance)
                {
                    type = ChatTypeEnum.Say;
                }
            }

            presence.ControllingClient.SendChatMessage(message, (byte)type, fromPos, fromName,
                                                       fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully);
        }
Exemplo n.º 9
0
        static private string ChatTemplateSelector(TableRow_Messages msg, ChatTypeEnum chatType, bool isChatHeader, bool isKeyFromMe, ColorPicker chatOwnerColor)
        {
            switch (chatType)
            {
            case ChatTypeEnum.normalChat:
                return(FormatNormalChat(msg, isChatHeader, isKeyFromMe, chatOwnerColor));

            case ChatTypeEnum.normalChatReply:
                return(FormatNormalChatReply(msg, isChatHeader, isKeyFromMe, chatOwnerColor));

            case ChatTypeEnum.image:
                return(FormatImage(msg, isChatHeader, isKeyFromMe, chatOwnerColor));

            case ChatTypeEnum.imageReply:
                return(FormatImageReply(msg, isChatHeader, isKeyFromMe, chatOwnerColor));

            case ChatTypeEnum.video:
                return(FormatVideo(msg, isChatHeader, isKeyFromMe, chatOwnerColor));

            case ChatTypeEnum.videoReply:
                return(@"<li>video reply | temporarily do nothing</li>");

            case ChatTypeEnum.audio:
                return(@"<li>audio | temporarily do nothing</li>");

            case ChatTypeEnum.audioReply:
                return(@"<li>audio reply | temporarily do nothing</li>");

            default:
                return(@"<li style='color:red'> CHAT TYPE NOT CAUGHT!</li>");
                //throw new InvalidOperationException("ChatTemplate must have a valid value as listed in ChatTypeEnum");
                //to be logged
            }
        }
Exemplo n.º 10
0
        protected virtual void TrySendChatMessage(IScenePresence presence, Vector3 fromPos, Vector3 regionPos,
                                                  UUID fromAgentID, string fromName, ChatTypeEnum type,
                                                  string message, ChatSourceType src)
        {
            // don't send stuff to child agents
            if (presence.IsChildAgent)
            {
                return;
            }

            Vector3 fromRegionPos = fromPos + regionPos;
            Vector3 toRegionPos   = presence.AbsolutePosition +
                                    new Vector3(presence.Scene.RegionInfo.RegionLocX,
                                                presence.Scene.RegionInfo.RegionLocY, 0);

            int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);

            if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                type == ChatTypeEnum.Say && dis > m_saydistance ||
                type == ChatTypeEnum.Shout && dis > m_shoutdistance)
            {
                return;
            }

            presence.ControllingClient.SendChatMessage(message, (byte)type, fromPos, fromName,
                                                       fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully);
        }
Exemplo n.º 11
0
        private void SendOnChatFromClient(int channel, string message, ChatTypeEnum chatType)
        {
            if (OnChatFromClient == null)
            {
                return;
            }

            if (channel == 0)
            {
                message = message.Trim();
                if (string.IsNullOrEmpty(message))
                {
                    return;
                }
            }

            OSChatMessage chatFromClient = new OSChatMessage()
            {
                Channel    = channel,
                From       = Name,
                Message    = message,
                Position   = StartPos,
                Scene      = m_scene,
                Sender     = this,
                SenderUUID = AgentId,
                Type       = chatType
            };

            OnChatFromClient?.Invoke(this, chatFromClient);
        }
Exemplo n.º 12
0
 public Message(string _whoSaid, string _whatSaid, ChatTypeEnum _chatTypeEnum = ChatTypeEnum.Default, string _name_chat = "Default")
 {
     whoSaid      = _whoSaid;
     whatSaid     = _whatSaid;
     chatTypeEnum = _chatTypeEnum;
     name_chat    = _name_chat;
 }
Exemplo n.º 13
0
        public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg)
        {
            Vector3         position;
            SceneObjectPart source;
            ScenePresence   avatar;

            if ((source = m_scene.GetSceneObjectPart(id)) != null)
            {
                position = source.AbsolutePosition;
            }
            else if ((avatar = m_scene.GetScenePresence(id)) != null)
            {
                position = avatar.AbsolutePosition;
            }
            else if (ChatTypeEnum.Region == type)
            {
                position = CenterOfRegion;
            }
            else
            {
                return;
            }

            DeliverMessage(type, channel, name, id, msg, position);
        }
Exemplo n.º 14
0
        public bool ShouldChatCrossRegions(ChatTypeEnum type)
        {
            switch (type)
            {
            case ChatTypeEnum.Whisper:      return(true);

            case ChatTypeEnum.Say:          return(true);

            case ChatTypeEnum.Shout:        return(true);

            case (ChatTypeEnum)3:           return(true);       // 3 is an obsolete version of Say

            case ChatTypeEnum.StartTyping:  return(false);

            case ChatTypeEnum.StopTyping:   return(false);

            case ChatTypeEnum.DebugChannel: return(false);

            case ChatTypeEnum.Region:       return(false);

            case ChatTypeEnum.Owner:        return(false);

            case ChatTypeEnum.Direct:       return(false);      // llRegionSayTo

            case ChatTypeEnum.Broadcast:    return(true);
            }
            return(false);   // by default, new types will stay within the region
        }
Exemplo n.º 15
0
        /// <summary>
        /// This method scans over the objects which registered an interest in listen callbacks.
        /// For everyone it finds, it checks if it fits the given filter. If it does,  then
        /// enqueue the message for delivery to the objects listen event handler.
        /// The enqueued ListenerInfo no longer has filter values, but the actually trigged values.
        /// Objects that do an llSay have their messages delivered here and for nearby avatars,
        /// the OnChatFromClient event is used.
        /// </summary>
        /// <param name="type">type of delvery (whisper,say,shout or regionwide)</param>
        /// <param name="channel">channel to sent on</param>
        /// <param name="name">name of sender (object or avatar)</param>
        /// <param name="id">key of sender (object or avatar)</param>
        /// <param name="msg">msg to sent</param>
        public void DeliverMessage(ChatTypeEnum type, int channel,
                                   string name, UUID id, string msg, Vector3 position)
        {
            // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}",
            //                   type, channel, name, id, msg);

            // Determine which listen event filters match the given set of arguments, this results
            // in a limited set of listeners, each belonging a host. If the host is in range, add them
            // to the pending queue.

            foreach (ListenerInfo li
                     in m_listenerManager.GetListeners(UUID.Zero, channel,
                                                       name, id, msg))
            {
                // Dont process if this message is from yourself!
                if (li.GetHostID().Equals(id))
                {
                    continue;
                }

                SceneObjectPart sPart = m_scene.GetSceneObjectPart(
                    li.GetHostID());
                if (sPart == null)
                {
                    continue;
                }

                double dis = Util.GetDistanceTo(sPart.AbsolutePosition,
                                                position);
                switch (type)
                {
                case ChatTypeEnum.Whisper:
                    if (dis < m_whisperdistance)
                    {
                        QueueMessage(new ListenerInfo(li, name, id, msg));
                    }
                    break;

                case ChatTypeEnum.Say:
                    if (dis < m_saydistance)
                    {
                        QueueMessage(new ListenerInfo(li, name, id, msg));
                    }
                    break;

                case ChatTypeEnum.Shout:
                    if (dis < m_shoutdistance)
                    {
                        QueueMessage(new ListenerInfo(li, name, id, msg));
                    }
                    break;

                case ChatTypeEnum.Region:
                    QueueMessage(new ListenerInfo(li, name, id, msg));
                    break;
                }
            }
        }
Exemplo n.º 16
0
 public UserChatEvent(
     UUID userId, string userName, Vector3 origin, ChatTypeEnum chatType, string text, int channel, string gridId, string regionName, DateTime datetime)
     : base(userId, userName, "chat", gridId, regionName, datetime)
 {
     Origin   = origin;
     ChatType = chatType;
     Text     = text;
     Channel  = channel;
 }
 public UserChatEvent(
     UUID userId, string userName, Vector3 origin, ChatTypeEnum chatType, string text, int channel, string gridId, string regionName, DateTime datetime)
     : base(userId, userName, "chat", gridId, regionName, datetime)
 {
     Origin = origin;
     ChatType = chatType;
     Text = text;
     Channel = channel;
 }
Exemplo n.º 18
0
        public bool BotChat(UUID botID, int channel, string message, ChatTypeEnum sourceType, UUID attemptingUser)
        {
            IBot bot;

            if ((bot = GetBotWithPermission(botID, attemptingUser)) == null)
            {
                return(false);
            }

            bot.Say(channel, message, sourceType);
            return(true);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Try to send a message to the given presence
        /// </summary>
        /// <param name="presence">The receiver</param>
        /// <param name="fromPos"></param>
        /// <param name="regionPos">/param>
        /// <param name="fromAgentID"></param>
        /// <param name='ownerID'>
        /// Owner of the message.  For at least some messages from objects, this has to be correctly filled with the owner's UUID.
        /// This is the case for script error messages in viewer 3 since LLViewer change EXT-7762
        /// </param>
        /// <param name="fromName"></param>
        /// <param name="type"></param>
        /// <param name="message"></param>
        /// <param name="src"></param>
        /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a
        /// precondition</returns>
        protected virtual bool TrySendChatMessage(
            ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
            UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type,
            string message, ChatSourceType src, bool ignoreDistance)
        {
            if (presence.IsDeleted || presence.IsInTransit || !presence.ControllingClient.IsActive)
            {
                return(false);
            }

            if (!ignoreDistance)
            {
                float maxDistSQ;
                switch (type)
                {
                case ChatTypeEnum.Whisper:
                    maxDistSQ = m_whisperdistanceSQ;
                    break;

                case ChatTypeEnum.Say:
                    maxDistSQ = m_saydistanceSQ;
                    break;

                case ChatTypeEnum.Shout:
                    maxDistSQ = m_shoutdistanceSQ;
                    break;

                default:
                    maxDistSQ = -1f;
                    break;
                }

                if (maxDistSQ > 0)
                {
                    Vector3 fromRegionPos = fromPos + regionPos;
                    Vector3 toRegionPos   = presence.AbsolutePosition +
                                            new Vector3(presence.Scene.RegionInfo.WorldLocX, presence.Scene.RegionInfo.WorldLocY, 0);

                    if (maxDistSQ < Vector3.DistanceSquared(toRegionPos, fromRegionPos))
                    {
                        return(false);
                    }
                }
            }

            // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
            presence.ControllingClient.SendChatMessage(
                message, (byte)type, fromPos, fromName,
                fromAgentID, ownerID, (byte)src, (byte)ChatAudibleLevel.Fully);

            return(true);
        }
Exemplo n.º 20
0
        protected void ProcessChatToClients(UUID senderID, HashSet <UUID> receiverIDs,
                                            string message, ChatTypeEnum type, Vector3 fromPos, string fromName,
                                            ChatSourceType src, ChatAudibleLevel level)
        {
            if (null == m_xtw)
            {
                return;
            }

            if (ChatTypeEnum.DebugChannel == type | ChatTypeEnum.StartTyping == type | ChatTypeEnum.StopTyping == type)
            {
                return;
            }

            Player        speaker;
            List <Player> heardBy = new List <Player>();

            lock (m_controller.Game.Players)
            {
                m_controller.Game.Players.TryGetValue(senderID, out speaker);

                if (null == speaker)
                {
                    return;
                }

                foreach (UUID receiverId in receiverIDs)
                {
                    if (m_controller.Game.Players.ContainsKey(receiverId))
                    {
                        heardBy.Add(m_controller.Game.Players[receiverId]);
                    }
                }
            }

            lock (this)
            {
                RecordEventStart(ChatElement);
                m_xtw.WriteStartElement(SpeakerElement);
                RecordPlayerReference(speaker);
                m_xtw.WriteEndElement();
                m_xtw.WriteStartElement(HeardByElement);
                foreach (Player p in heardBy)
                {
                    RecordPlayerReference(p);
                }
                m_xtw.WriteEndElement();
                m_xtw.WriteElementString(MessageElement, message);
                RecordEventEnd();
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 清除消息未读状态
        /// </summary>
        /// <param name="opUser">会话所有者的userid</param>
        /// <param name="type">会话类型:single|group,分别表示:群聊|单聊</param>
        /// <param name="chatIdOrUserId">会话值,为userid|chatid,分别表示:成员id|会话id,单聊是userid,群聊是chatid</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public QyJsonResult ClearNotify(string opUser, ChatTypeEnum type, string chatIdOrUserId)
        {
            var data = new
            {
                op_user = opUser,
                chat    = new
                {
                    type = type,
                    id   = chatIdOrUserId
                }
            };

            return(this.Post <QyJsonResult>(string.Format("https://qyapi.weixin.qq.com/cgi-bin/chat/clearnotify?access_token={0}", AccessToken.access_token), data));
        }
Exemplo n.º 22
0
        private void SendOnChatFromClient(string message, ChatTypeEnum chatType)
        {
            OSChatMessage chatFromClient = new OSChatMessage();

            chatFromClient.Channel    = 0;
            chatFromClient.From       = Name;
            chatFromClient.Message    = message;
            chatFromClient.Position   = StartPos;
            chatFromClient.Scene      = m_scene;
            chatFromClient.Sender     = this;
            chatFromClient.SenderUUID = AgentId;
            chatFromClient.Type       = chatType;

            OnChatFromClient(this, chatFromClient);
        }
Exemplo n.º 23
0
    public static void BtnChangeLastCommunication(ChatTypeEnum chatType, string name_chat)
    {
        BtnChatManager.lastClickedEnum = chatType;
        BtnChatManager.name_chat       = name_chat;


        ChatManager.instance.RefreshChat();

        for (int i = 0; i < BtnChatManager.ChatTypeOpen.Count; i++)
        {
            if (BtnChatManager.ChatTypeOpen[i].name_chat == name_chat)
            {
                BtnChatManager.ChatTypeOpen[i].colorChange = false;
            }
        }
    }
Exemplo n.º 24
0
        protected virtual void TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
                                                  UUID fromAgentID, string fromName, ChatTypeEnum type,
                                                  string message, ChatSourceType src)
        {
            if ((presence.Scene.RegionInfo.RegionLocX != ((uint)regionPos.X) / Constants.RegionSize) ||
                (presence.Scene.RegionInfo.RegionLocY != ((uint)regionPos.Y) / Constants.RegionSize))
            {   // Different region?
                if (!ShouldChatCrossRegions(type))
                {
                    return;
                }
            }

            Vector3 fromRegionPos = fromPos + regionPos;
            Vector3 toRegionPos   = presence.AbsolutePosition +
                                    new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
                                                presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

            // fix the exception that happens if
            double fdist = Util.GetDistanceTo(toRegionPos, fromRegionPos);

            if (fdist > (double)Int32.MaxValue)
            {
                return;
            }
            if (fdist < -(double)Int32.MaxValue)
            {
                return;
            }
            int dis = Math.Abs((int)fdist);     // throws an exception on the cast if out of range

            if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                type == ChatTypeEnum.Say && dis > m_saydistance ||
                type == ChatTypeEnum.Shout && dis > m_shoutdistance)
            {
                return;
            }

            presence.Scene.EventManager.TriggerOnChatToClient(message, fromAgentID,
                                                              presence.UUID, presence.Scene.RegionInfo.RegionID, (uint)Util.UnixTimeSinceEpoch(),
                                                              ChatToClientType.InworldChat);
            // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
            presence.ControllingClient.SendChatMessage(message, (byte)type, fromPos, fromName, fromAgentID,
                                                       fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully);
        }
Exemplo n.º 25
0
    private void CreateNewPrivateDialog(string nick, ChatTypeEnum chatTypeEnum = ChatTypeEnum.Private, bool canClose = false)
    {
        ChatType newChatBtn = (Instantiate(GUIHandler.instance.prefabChatBtn, GUIHandler.instance.ChatSwitchPanel.transform)).GetComponent <ChatType>();

        newChatBtn._chatTypeEnum = chatTypeEnum;
        newChatBtn.name_chat     = nick;
        newChatBtn.canClose      = canClose;

        newChatBtn.Initialize();

        BtnChatManager.ChatTypeOpen.Add(newChatBtn);
        GUIHandler.instance.MenuCreateNewChat.SetActive(false);
        newChatBtn.GetComponent <Button>().onClick.AddListener(() => BtnChatManager.BtnChangeLastCommunication(newChatBtn._chatTypeEnum, newChatBtn.name_chat));


        BtnChatManager.BtnChangeLastCommunication(newChatBtn._chatTypeEnum, newChatBtn.name_chat);
        RefreshChat();
    }
Exemplo n.º 26
0
        public void SimChat(string message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                            UUID fromID, bool fromAgent, bool broadcast, float range, UUID ToAgentID, IScene scene)
        {
            OSChatMessage args = new OSChatMessage
            {
                Message    = message,
                Channel    = channel,
                Type       = type,
                Position   = fromPos,
                Range      = range,
                SenderUUID = fromID,
                Scene      = scene,
                ToAgentID  = ToAgentID
            };


            if (fromAgent)
            {
                IScenePresence user = scene.GetScenePresence(fromID);
                if (user != null)
                {
                    args.Sender = user.ControllingClient;
                }
            }
            else
            {
                args.SenderObject = scene.GetSceneObjectPart(fromID);
            }

            args.From = fromName;
            //args.

            if (broadcast)
            {
                OnChatBroadcast(scene, args);
                scene.EventManager.TriggerOnChatBroadcast(scene, args);
            }
            else
            {
                OnChatFromWorld(scene, args);
                scene.EventManager.TriggerOnChatFromWorld(scene, args);
            }
        }
Exemplo n.º 27
0
        private void chat(UUID agent, string msg, ChatTypeEnum msgType, int channel)
        {
            UUID speaker = actors[agent].UUID;

            switch (msgType)
            {
            case ChatTypeEnum.Say:
                npc.Say(speaker, m_scene, msg, channel);
                break;

            case ChatTypeEnum.Shout:
                npc.Shout(speaker, m_scene, msg, channel);
                break;

            case ChatTypeEnum.Whisper:
                npc.Whisper(speaker, m_scene, msg, channel);
                break;
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Send chat to listeners.
        /// </summary>
        /// <param name='message'></param>
        /// <param name='type'>/param>
        /// <param name='channel'></param>
        /// <param name='fromPos'></param>
        /// <param name='fromName'></param>
        /// <param name='fromID'></param>
        /// <param name='targetID'></param>
        /// <param name='fromAgent'></param>
        /// <param name='broadcast'></param>
        public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                            UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
        {
            OSChatMessage args = new OSChatMessage();

            args.Message     = Utils.BytesToString(message);
            args.Channel     = channel;
            args.Type        = type;
            args.Position    = fromPos;
            args.SenderUUID  = fromID;
            args.Scene       = this;
            args.Destination = targetID;

            if (fromAgent)
            {
                ScenePresence user = GetScenePresence(fromID);
                if (user != null)
                {
                    args.Sender = user.ControllingClient;
                }
            }
            else
            {
                SceneObjectPart obj = GetSceneObjectPart(fromID);
                args.SenderObject = obj;
            }

            args.From = fromName;
            //args.

//            m_log.DebugFormat(
//                "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}",
//                args.Message.Replace("\n", "\\n"), args.Channel, args.Type, fromName, broadcast);

            if (broadcast)
            {
                EventManager.TriggerOnChatBroadcast(this, args);
            }
            else
            {
                EventManager.TriggerOnChatFromWorld(this, args);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Trigger chat coming from this connection.
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="type"></param>
        /// <param name="message"></param>
        public bool Chat(int channel, ChatTypeEnum type, string message)
        {
            ChatMessage handlerChatFromClient = OnChatFromClient;

            if (handlerChatFromClient != null)
            {
                OSChatMessage args = new OSChatMessage();
                args.Channel = channel;
                args.From    = Name;
                args.Message = message;
                args.Type    = type;

                args.Scene      = Scene;
                args.Sender     = this;
                args.SenderUUID = AgentId;

                handlerChatFromClient(this, args);
            }

            return(true);
        }
Exemplo n.º 30
0
        protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                               UUID fromID, bool fromAgent, bool broadcast)
        {
            OSChatMessage args = new OSChatMessage();

            args.Message    = Utils.BytesToString(message);
            args.Channel    = channel;
            args.Type       = type;
            args.Position   = fromPos;
            args.SenderUUID = fromID;
            args.Scene      = this;

            if (fromAgent)
            {
                ScenePresence user = GetScenePresence(fromID);
                if (user != null)
                {
                    args.Sender = user.ControllingClient;
                }
            }
            else
            {
                SceneObjectPart obj = GetSceneObjectPart(fromID);
                args.SenderObject = obj;
            }

            args.From = fromName;
            //args.

            if (broadcast)
            {
                EventManager.TriggerOnChatBroadcast(this, args);
            }
            else
            {
                EventManager.TriggerOnChatFromWorld(this, args);
            }
        }
Exemplo n.º 31
0
        private void SendOnChatFromClient(int channel, string message, ChatTypeEnum chatType)
        {
            if (channel == 0)
            {
                message = message.Trim();
                if (string.IsNullOrEmpty(message))
                {
                    return;
                }
            }
            OSChatMessage chatFromClient = new OSChatMessage();

            chatFromClient.Channel    = channel;
            chatFromClient.From       = Name;
            chatFromClient.Message    = message;
            chatFromClient.Position   = StartPos;
            chatFromClient.Scene      = m_scene;
            chatFromClient.Sender     = this;
            chatFromClient.SenderUUID = AgentId;
            chatFromClient.Type       = chatType;

            OnChatFromClient(this, chatFromClient);
        }
        /// <summary>
        /// Send chat to listeners.
        /// </summary>
        /// <param name='message'></param>
        /// <param name='type'>/param>
        /// <param name='channel'></param>
        /// <param name='fromPos'></param>
        /// <param name='fromName'></param>
        /// <param name='fromID'></param>
        /// <param name='targetID'></param>
        /// <param name='fromAgent'></param>
        /// <param name='broadcast'></param>
        public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                               UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
        {
            OSChatMessage args = new OSChatMessage();

            args.Message = Utils.BytesToString(message);
            args.Channel = channel;
            args.Type = type;
            args.Position = fromPos;
            args.SenderUUID = fromID;
            args.Scene = this;
            args.Destination = targetID;

            if (fromAgent)
            {
                ScenePresence user = GetScenePresence(fromID);
                if (user != null)
                    args.Sender = user.ControllingClient;
            }
            else
            {
                SceneObjectPart obj = GetSceneObjectPart(fromID);
                args.SenderObject = obj;
            }

            args.From = fromName;
            //args.

//            m_log.DebugFormat(
//                "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}",
//                args.Message.Replace("\n", "\\n"), args.Channel, args.Type, fromName, broadcast);

            if (broadcast)
                EventManager.TriggerOnChatBroadcast(this, args);
            else
                EventManager.TriggerOnChatFromWorld(this, args);
        }
Exemplo n.º 33
0
        public void Say(int channel, string message, ChatTypeEnum sourceType)
        {
            if (m_frozenUser)
                return;

            if (channel == 0 && sourceType != ChatTypeEnum.StartTyping && sourceType != ChatTypeEnum.StopTyping)
            {
                message = message.Trim();
                if (string.IsNullOrEmpty(message))
                {
                    return;
                }
            }

            if (sourceType == ChatTypeEnum.StartTyping)
            {
                StartAnimation(UUID.Zero, "TYPE", UUID.Zero);
            }
            else if (sourceType == ChatTypeEnum.StopTyping)
            {
                StopAnimation(UUID.Zero, "TYPE");
            }

            OSChatMessage chatFromClient = new OSChatMessage();
            chatFromClient.Channel = channel;
            chatFromClient.From = Name;
            chatFromClient.Message = message;
            chatFromClient.Position = StartPos;
            chatFromClient.Scene = m_scene;
            chatFromClient.SenderUUID = AgentId;
            chatFromClient.Type = sourceType;

            // Force avatar position to be server-known avatar position. (Former contents of FixPositionOfChatMessage.)
            ScenePresence avatar;
            if (m_scene.TryGetAvatar(m_UUID, out avatar))
                chatFromClient.Position = avatar.AbsolutePosition;

            OnChatFromClient(this, chatFromClient);
        }
Exemplo n.º 34
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 /// <param name="type"></param>
 /// <param name="fromPos"></param>
 /// <param name="fromName"></param>
 /// <param name="fromAgentID"></param>
 /// 
 public void SimChat(string message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                     UUID fromID, bool fromAgent, float range)
 {
     SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, false, range, UUID.Zero);
 }
Exemplo n.º 35
0
        public bool BotChat(UUID botID, int channel, string message, ChatTypeEnum sourceType, UUID attemptingUser)
        {
            IBot bot;
            if ((bot = GetBotWithPermission(botID, attemptingUser)) == null)
                return false;

            bot.Say(channel, message, sourceType);
            return true;
        }
Exemplo n.º 36
0
        private void SendOnChatFromClient(int channel, string message, ChatTypeEnum chatType)
        {
            if (channel == 0)
            {
                message = message.Trim();
                if (string.IsNullOrEmpty(message))
                {
                    return;
                }
            }
            OSChatMessage chatFromClient = new OSChatMessage();
            chatFromClient.Channel = channel;
            chatFromClient.From = Name;
            chatFromClient.Message = message;
            chatFromClient.Position = StartPos;
            chatFromClient.Scene = m_scene;
            chatFromClient.Sender = this;
            chatFromClient.SenderUUID = AgentId;
            chatFromClient.Type = chatType;

            OnChatFromClient(this, chatFromClient);
        }
 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                        UUID fromID, bool fromAgent, bool broadcast)
 {
     SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast);
 }
Exemplo n.º 38
0
        public void SimChat(string message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                            UUID fromID, bool fromAgent, bool broadcast, float range, UUID ToAgentID, IScene scene)
        {
            OSChatMessage args = new OSChatMessage
                                     {
                                         Message = message,
                                         Channel = channel,
                                         Type = type,
                                         Position = fromPos,
                                         Range = range,
                                         SenderUUID = fromID,
                                         Scene = scene,
                                         ToAgentID = ToAgentID
                                     };


            if (fromAgent)
            {
                IScenePresence user = scene.GetScenePresence(fromID);
                if (user != null)
                    args.Sender = user.ControllingClient;
            }
            else
            {
                args.SenderObject = scene.GetSceneObjectPart(fromID);
            }

            args.From = fromName;
            //args.

            if (broadcast)
            {
                OnChatBroadcast(scene, args);
                scene.EventManager.TriggerOnChatBroadcast(scene, args);
            }
            else
            {
                OnChatFromWorld(scene, args);
                scene.EventManager.TriggerOnChatFromWorld(scene, args);
            }
        }
Exemplo n.º 39
0
        private void SendOnChatFromClient(string message, ChatTypeEnum chatType)
        {
            OSChatMessage chatFromClient = new OSChatMessage();
            chatFromClient.Channel = 0;
            chatFromClient.From = Name;
            chatFromClient.Message = message;
            chatFromClient.Position = StartPos;
            chatFromClient.Scene = m_scene;
            chatFromClient.Sender = this;
            chatFromClient.SenderUUID = AgentId;
            chatFromClient.Type = chatType;

            OnChatFromClient(this, chatFromClient);
        }
        /// <summary>
        ///     This method scans over the objects which registered an interest in listen callbacks.
        ///     For everyone it finds, it checks if it fits the given filter. If it does,  then
        ///     enqueue the message for delivery to the objects listen event handler.
        ///     The enqueued ListenerInfo no longer has filter values, but the actually trigged values.
        ///     Objects that do an llSay have their messages delivered here and for nearby avatars,
        ///     the OnChatFromClient event is used.
        /// </summary>
        /// <param name="type">type of delivery (whisper,say,shout or regionwide)</param>
        /// <param name="channel">channel to sent on</param>
        /// <param name="name">name of sender (object or avatar)</param>
        /// <param name="fromID">key of sender (object or avatar)</param>
        /// <param name="msg">msg to sent</param>
        /// <param name="position"></param>
        /// <param name="range"></param>
        /// <param name="toID"></param>
        public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID fromID, string msg,
            Vector3 position,
            float range, UUID toID)
        {
            //Make sure that the cmd handler thread is running
            m_scriptModule.PokeThreads(UUID.Zero);
            if (BlockedChannels.Contains(channel))
                return;
            // MainConsole.Instance.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}",
            //                   type, channel, name, id, msg);

            // Determine which listen event filters match the given set of arguments, this results
            // in a limited set of listeners, each belonging a host. If the host is in range, add them
            // to the pending queue.
            foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, fromID, msg))
            {
                // Dont process if this message is from yourself!
                if (li.GetHostID().Equals(fromID))
                    continue;

                ISceneChildEntity sPart = m_scene.GetSceneObjectPart(li.GetHostID());
                if (sPart == null)
                    continue;

                if (toID != UUID.Zero)
                    if (sPart.UUID != toID &&
                        sPart.AttachedAvatar != toID)
                        continue;
                //Only allow the message to go on if it is an attachment with the given avatars ID or the part ID is right

                double dis = Util.GetDistanceTo(sPart.AbsolutePosition, position);
                switch (type)
                {
                    case ChatTypeEnum.Whisper:
                        if (dis < m_whisperdistance)
                            QueueMessage(new ListenerInfo(li, name, fromID, msg));
                        break;

                    case ChatTypeEnum.Say:
                        if (dis < m_saydistance)
                            QueueMessage(new ListenerInfo(li, name, fromID, msg));
                        break;

                    case ChatTypeEnum.ObsoleteSay:
                        if (dis < m_saydistance)
                            QueueMessage(new ListenerInfo(li, name, fromID, msg));
                        break;

                    case ChatTypeEnum.Shout:
                        if (dis < m_shoutdistance)
                            QueueMessage(new ListenerInfo(li, name, fromID, msg));
                        break;

                    case ChatTypeEnum.Custom:
                        if (dis < range)
                            QueueMessage(new ListenerInfo(li, name, fromID, msg));
                        break;

                    case ChatTypeEnum.Region:
                        QueueMessage(new ListenerInfo(li, name, fromID, msg));
                        break;
                }
            }
        }
 public void FromKVP(Dictionary<string, object> kvp)
 {
     Message = kvp["Message"].ToString();
     Type = ((ChatTypeEnum) int.Parse(kvp["Type"].ToString()));
     Channel = int.Parse(kvp["Channel"].ToString());
     Range = float.Parse(kvp["Range"].ToString());
     Position = Vector3.Parse(kvp["Position"].ToString());
     From = kvp["From"].ToString();
     SenderUUID = UUID.Parse(kvp["SenderUUID"].ToString());
     ToAgentID = UUID.Parse(kvp["ToAgentID"].ToString());
 }
Exemplo n.º 42
0
        protected virtual void TrySendChatMessage(IScenePresence presence, Vector3 fromPos, Vector3 regionPos,
                                                  UUID fromAgentID, string fromName, ChatTypeEnum type,
                                                  string message, ChatSourceType src)
        {
            // don't send stuff to child agents
            if (presence.IsChildAgent) return;

            Vector3 fromRegionPos = fromPos + regionPos;
            Vector3 toRegionPos = presence.AbsolutePosition +
                                  new Vector3(presence.Scene.RegionInfo.RegionLocX,
                                              presence.Scene.RegionInfo.RegionLocY, 0);

            int dis = (int) Util.GetDistanceTo(toRegionPos, fromRegionPos);

            if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                type == ChatTypeEnum.Say && dis > m_saydistance ||
                type == ChatTypeEnum.Shout && dis > m_shoutdistance)
            {
                return;
            }

            presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
                                                       fromAgentID, (byte) src, (byte) ChatAudibleLevel.Fully);
        }
Exemplo n.º 43
0
        public virtual void TrySendChatMessage(IScenePresence presence, Vector3 fromPos,
            UUID fromAgentID, string fromName, ChatTypeEnum type,
            string message, ChatSourceType src, float Range)
        {
            if (type == ChatTypeEnum.Custom)
            {
                int dis = (int)Util.GetDistanceTo(fromPos, presence.AbsolutePosition);
                //Set the best fitting setting for custom
                if (dis < m_whisperdistance)
                    type = ChatTypeEnum.Whisper;
                else if (dis > m_saydistance)
                    type = ChatTypeEnum.Shout;
                else if (dis > m_whisperdistance && dis < m_saydistance)
                    type = ChatTypeEnum.Say;
            }

            presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
                                                       fromAgentID, (byte) src, (byte) ChatAudibleLevel.Fully);
        }
 /// <summary>
 /// Sends a chat message to clients in the region
 /// </summary>
 /// <param name="message">The message to send to users</param>
 /// <param name="type">The type of message (say, shout, whisper, owner say, etc)</param>
 /// <param name="channel">The channel to speak the message on</param>
 /// <param name="part">The SceneObjectPart that is sending this chat message</param>
 public void SimChat(string message, ChatTypeEnum type, int channel, SceneObjectPart part)
 {
     SimChat(message, type, channel, part.AbsolutePosition, part.Name, part.UUID, UUID.Zero, part.OwnerID, false);
 }
 /// <summary>
 /// Sends a chat message to clients in the region
 /// </summary>
 /// <param name="message">The message to send to users</param>
 /// <param name="type">The type of message (say, shout, whisper, owner say, etc)</param>
 /// <param name="channel">The channel to speak the message on</param>
 /// <param name="presence">The ScenePresence that is sending this chat message</param>
 public void SimChat(string message, ChatTypeEnum type, int channel, ScenePresence presence)
 {
     SimChat(message, type, channel, presence.AbsolutePosition, presence.Name, presence.UUID, UUID.Zero, presence.UUID, false);
 }
Exemplo n.º 46
0
        public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg)
        {
            Vector3 position;
            SceneObjectPart source;
            ScenePresence avatar;

            if ((source = m_scene.GetSceneObjectPart(id)) != null)
                position = source.AbsolutePosition;
            else if ((avatar = m_scene.GetScenePresence(id)) != null)
                position = avatar.AbsolutePosition;
            else if (ChatTypeEnum.Region == type)
                position = CenterOfRegion;
            else
                return;

            DeliverMessage(type, channel, name, id, msg, position);
        }
Exemplo n.º 47
0
        /// <summary>
        /// This method scans over the objects which registered an interest in listen callbacks.
        /// For everyone it finds, it checks if it fits the given filter. If it does,  then
        /// enqueue the message for delivery to the objects listen event handler.
        /// The enqueued ListenerInfo no longer has filter values, but the actually trigged values.
        /// Objects that do an llSay have their messages delivered here and for nearby avatars,
        /// the OnChatFromClient event is used.
        /// </summary>
        /// <param name="type">type of delvery (whisper,say,shout or regionwide)</param>
        /// <param name="channel">channel to sent on</param>
        /// <param name="name">name of sender (object or avatar)</param>
        /// <param name="id">key of sender (object or avatar)</param>
        /// <param name="msg">msg to sent</param>
        public void DeliverMessage(ChatTypeEnum type, int channel,
                string name, UUID id, string msg, Vector3 position)
        {
            // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}",
            //                   type, channel, name, id, msg);

            // Determine which listen event filters match the given set of arguments, this results
            // in a limited set of listeners, each belonging a host. If the host is in range, add them
            // to the pending queue.
            foreach (ListenerInfo li
                    in m_listenerManager.GetListeners(UUID.Zero, channel,
                    name, id, msg))
            {
                // Dont process if this message is from yourself!
                if (li.GetHostID().Equals(id))
                    continue;

                SceneObjectPart sPart = m_scene.GetSceneObjectPart(
                        li.GetHostID());
                if (sPart == null)
                    continue;

                double dis = Util.GetDistanceTo(sPart.AbsolutePosition,
                        position);
                switch (type)
                {
                    case ChatTypeEnum.Whisper:
                        if (dis < m_whisperdistance)
                            QueueMessage(new ListenerInfo(li, name, id, msg));
                        break;

                    case ChatTypeEnum.Say:
                        if (dis < m_saydistance)
                            QueueMessage(new ListenerInfo(li, name, id, msg));
                        break;

                    case ChatTypeEnum.Shout:
                        if (dis < m_shoutdistance)
                            QueueMessage(new ListenerInfo(li, name, id, msg));
                        break;

                    case ChatTypeEnum.Region:
                        QueueMessage(new ListenerInfo(li, name, id, msg));
                        break;
                }
            }
        }
Exemplo n.º 48
0
 /// <summary>
 ///   Say this message directly to a single person
 /// </summary>
 /// <param name = "message"></param>
 /// <param name = "type"></param>
 /// <param name = "fromPos"></param>
 /// <param name = "fromName"></param>
 /// <param name = "fromAgentID"></param>
 public void SimChatBroadcast(string message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                              UUID fromID, bool fromAgent, UUID ToAgentID, IScene scene)
 {
     SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true, -1, ToAgentID, scene);
 }
Exemplo n.º 49
0
 public bool ShouldChatCrossRegions(ChatTypeEnum type)
 {
     switch (type)
     {
         case ChatTypeEnum.Whisper:      return true;
         case ChatTypeEnum.Say:          return true;
         case ChatTypeEnum.Shout:        return true;
         case (ChatTypeEnum)3:           return true;    // 3 is an obsolete version of Say
         case ChatTypeEnum.StartTyping:  return false;
         case ChatTypeEnum.StopTyping:   return false;
         case ChatTypeEnum.DebugChannel: return false;
         case ChatTypeEnum.Region:       return false;
         case ChatTypeEnum.Owner:        return false;
         case ChatTypeEnum.Direct:       return false;   // llRegionSayTo
         case ChatTypeEnum.Broadcast:    return true;
     }
     return false;   // by default, new types will stay within the region
 }
Exemplo n.º 50
0
 public void TriggerOnChatToClients(
     UUID senderID, HashSet<UUID> receiverIDs, 
     string message, ChatTypeEnum type, Vector3 fromPos, string fromName, 
     ChatSourceType src, ChatAudibleLevel level)
 {
     ChatToClientsEvent handler = OnChatToClients;
     if (handler != null)
     {
         foreach (ChatToClientsEvent d in handler.GetInvocationList())
         {
             try
             {
                 d(senderID, receiverIDs, message, type, fromPos, fromName, src, level);
             }
             catch (Exception e)
             {
                 m_log.ErrorFormat(
                     "[EVENT MANAGER]: Delegate for TriggerOnChatToClients failed - continuing.  {0} {1}", 
                     e.Message, e.StackTrace);
             }
         }
     }
 }
Exemplo n.º 51
0
 public void SimChat(string message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                     UUID fromID, bool fromAgent, IScene scene)
 {
     SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, false, -1, UUID.Zero, scene);
 }
 /// <summary>
 /// Sends a chat message to clients in the region
 /// </summary>
 /// <param name="message">The message to send to users</param>
 /// <param name="type">The type of message (say, shout, whisper, owner say, etc)</param>
 /// <param name="channel">The channel to speak the message on</param>
 /// <param name="part">The SceneObjectPart that is sending this chat message</param>
 /// <param name="destID">The user or object that is being spoken to (UUID.Zero specifies all users will get the message)</param>
 /// <param name="broadcast">Whether the message will be sent regardless of distance from the sender</param>
 public void SimChat(string message, ChatTypeEnum type, int channel, SceneObjectPart part,
     UUID destID, bool broadcast = false)
 {
     SimChat(message, type, channel, part.AbsolutePosition, part.Name, part.UUID, destID, part.OwnerID, broadcast);
 }
Exemplo n.º 53
0
        public virtual void TrySendChatMessage(IScenePresence presence, Vector3 fromPos, Vector3 regionPos,
                                               UUID fromAgentID, string fromName, ChatTypeEnum type,
                                               string message, ChatSourceType src, float Range)
        {
            if (type == ChatTypeEnum.Custom)
            {
                Vector3 fromRegionPos = fromPos + regionPos;
                Vector3 toRegionPos = presence.AbsolutePosition +
                                      new Vector3(presence.Scene.RegionInfo.RegionLocX,
                                                  presence.Scene.RegionInfo.RegionLocY, 0);

                int dis = (int) Util.GetDistanceTo(toRegionPos, fromRegionPos);
                //Set the best fitting setting for custom
                if (dis < m_whisperdistance)
                    type = ChatTypeEnum.Whisper;
                else if (dis > m_saydistance)
                    type = ChatTypeEnum.Shout;
                else if (dis > m_whisperdistance && dis < m_saydistance)
                    type = ChatTypeEnum.Say;
            }

            // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
            presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
                                                       fromAgentID, (byte) src, (byte) ChatAudibleLevel.Fully);
        }
        /// <summary>
        /// Sends a chat message to clients in the region
        /// </summary>
        /// <param name="message">The message to send to users</param>
        /// <param name="type">The type of message (say, shout, whisper, owner say, etc)</param>
        /// <param name="channel">The channel to speak the message on</param>
        /// <param name="fromPos">The position of the speaker (the SceneObjectPart or ScenePresence)</param>
        /// <param name="fromName">The name of the speaker (the SceneObjectPart or ScenePresence)</param>
        /// <param name="fromID">The UUID of the speaker (the SceneObjectPart or ScenePresence)</param>
        /// <param name="destID">The user or object that is being spoken to (UUID.Zero specifies all users will get the message)</param>
        /// <param name="generatingAvatarID">The avatar ID that has generated this message regardless of
        /// if it is a script owned by this avatar, or the avatar itself</param>
        /// <param name="broadcast">Whether the message will be sent regardless of distance from the sender</param>
        public void SimChat(string message, ChatTypeEnum type, int channel, Vector3 fromPos,
            string fromName, UUID fromID, UUID destID, UUID generatingAvatarID, bool broadcast)
        {
            OSChatMessage args = new OSChatMessage()
            {
                Channel = channel,
                DestinationUUID = destID,
                From = fromName,
                GeneratingAvatarID = generatingAvatarID,
                Message = message,
                Position = fromPos,
                Scene = this,
                SenderUUID = fromID,
                Type = type
            };

            if (broadcast)
                EventManager.TriggerOnChatBroadcast(this, args);
            else
                EventManager.TriggerOnChatFromWorld(this, args);
        }
Exemplo n.º 55
0
 public void SimChat(string message, ChatTypeEnum type, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
 {
     SimChat(Utils.StringToBytes(message), type, 0, fromPos, fromName, fromID, fromAgent);
 }
Exemplo n.º 56
0
        /// <summary>
        /// Try to send a message to the given presence
        /// </summary>
        /// <param name="presence">The receiver</param>
        /// <param name="fromPos"></param>
        /// <param name="regionPos">/param>
        /// <param name="fromAgentID"></param>
        /// <param name='ownerID'>
        /// Owner of the message.  For at least some messages from objects, this has to be correctly filled with the owner's UUID.
        /// This is the case for script error messages in viewer 3 since LLViewer change EXT-7762
        /// </param>
        /// <param name="fromName"></param>
        /// <param name="type"></param>
        /// <param name="message"></param>
        /// <param name="src"></param>
        /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a 
        /// precondition</returns>
        protected virtual bool TrySendChatMessage(
            ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
            UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type,
            string message, ChatSourceType src, bool ignoreDistance)
        {
            if (presence.LifecycleState != ScenePresenceState.Running)
                return false;

            if (!ignoreDistance)
            {
                Vector3 fromRegionPos = fromPos + regionPos;
                Vector3 toRegionPos = presence.AbsolutePosition +
                    new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
                                presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

                int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);

                if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                    type == ChatTypeEnum.Say && dis > m_saydistance ||
                    type == ChatTypeEnum.Shout && dis > m_shoutdistance)
                {
                    return false;
                }
            }

            // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
            presence.ControllingClient.SendChatMessage(
                message, (byte) type, fromPos, fromName,
                fromAgentID, ownerID, (byte)src, (byte)ChatAudibleLevel.Fully);
            
            return true;
        }
Exemplo n.º 57
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 /// <param name="type"></param>
 /// <param name="fromPos"></param>
 /// <param name="fromName"></param>
 /// <param name="fromAgentID"></param>
 public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                     UUID fromID, bool fromAgent)
 {
     SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, false);
 }
 /// <summary>
 /// Sends a chat message to clients in the region
 /// </summary>
 /// <param name="message">The message to send to users</param>
 /// <param name="type">The type of message (say, shout, whisper, owner say, etc)</param>
 /// <param name="channel">The channel to speak the message on</param>
 /// <param name="presence">The ScenePresence that is sending this chat message</param>
 /// <param name="destID">The user or object that is being spoken to (UUID.Zero specifies all users will get the message)</param>
 /// <param name="broadcast">Whether the message will be sent regardless of distance from the sender</param>
 public void SimChat(string message, ChatTypeEnum type, int channel, ScenePresence presence,
     UUID destID, bool broadcast = false)
 {
     SimChat(message, type, channel, presence.AbsolutePosition, presence.Name, presence.UUID, destID, presence.UUID, broadcast);
 }
Exemplo n.º 59
0
 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
                        UUID fromID, bool fromAgent, bool broadcast)
 {
     SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast);
 }
Exemplo n.º 60
0
        protected virtual void TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
                                                  UUID fromAgentID, string fromName, ChatTypeEnum type,
                                                  string message, ChatSourceType src)
        {
            if ((presence.Scene.RegionInfo.RegionLocX != ((uint)regionPos.X) / Constants.RegionSize) ||
                (presence.Scene.RegionInfo.RegionLocY != ((uint)regionPos.Y) / Constants.RegionSize))
            {   // Different region?
                if (!ShouldChatCrossRegions(type))
                    return;
            }

            Vector3 fromRegionPos = fromPos + regionPos;
            Vector3 toRegionPos = presence.AbsolutePosition +
                new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
                            presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

            // fix the exception that happens if 
            double fdist = Util.GetDistanceTo(toRegionPos, fromRegionPos);
            if (fdist > (double)Int32.MaxValue)
                return;
            if (fdist < -(double)Int32.MaxValue)
                return;
            int dis = Math.Abs((int) fdist);    // throws an exception on the cast if out of range
            if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                type == ChatTypeEnum.Say && dis > m_saydistance ||
                type == ChatTypeEnum.Shout && dis > m_shoutdistance)
            {
                return;
            }

            presence.Scene.EventManager.TriggerOnChatToClient(message, fromAgentID,
                presence.UUID, presence.Scene.RegionInfo.RegionID, (uint)Util.UnixTimeSinceEpoch(), 
                ChatToClientType.InworldChat);
            // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
            presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
                                                       fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully);
        }