Ejemplo n.º 1
0
        /// <summary>
        /// Send the message from the prim to the avatars in the regions
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="c"></param>
        public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
        {
            // early return if not on public or debug channel
            if (c.Channel != DEFAULT_CHANNEL && c.Channel != DEBUG_CHANNEL)
            {
                return;
            }

            bool Sent = false;

            if (c.Range > m_maxChatDistance) //Check for max distance
            {
                c.Range = m_maxChatDistance;
            }

            OpenSim.Services.Interfaces.INeighborService neighborService = c.Scene.RequestModuleInterface <OpenSim.Services.Interfaces.INeighborService>();
            if (neighborService != null && c.Message != "")
            {
                Sent = neighborService.SendChatMessageToNeighbors(c, ChatSourceType.Object, c.Scene.RegionInfo);
            }

            if (!Sent)
            {
                DeliverChatToAvatars(ChatSourceType.Object, c);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// New chat message from the client
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="c"></param>
        protected virtual void OnChatFromClient(Object sender, OSChatMessage c)
        {
            c = FixPositionOfChatMessage(c);

            // redistribute to interested subscribers
            c.Scene.EventManager.TriggerOnChatFromClient(sender, c);

            // early return if not on public or debug channel
            if (c.Channel != DEFAULT_CHANNEL && c.Channel != DEBUG_CHANNEL)
            {
                return;
            }

            // sanity check:
            if (c.Sender == null)
            {
                m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender);
                return;
            }

            //If the message is not blank, tell the plugins about it
            if (c.Message != "")
            {
                foreach (string pluginMain in ChatPlugins.Keys)
                {
                    //if their plugin level is all or the message starts with the message, send the message to the plugin
                    if (pluginMain == "all" || c.Message.StartsWith(pluginMain + "."))
                    {
                        IChatPlugin plugin;
                        ChatPlugins.TryGetValue(pluginMain, out plugin);
                        //If it returns false, stop the message from being sent
                        if (!plugin.OnNewChatMessageFromWorld(c, out c))
                        {
                            return;
                        }
                    }
                }
            }
            bool Sent = false;

            OpenSim.Services.Interfaces.INeighborService neighborService = c.Scene.RequestModuleInterface <OpenSim.Services.Interfaces.INeighborService>();
            if (neighborService != null)
            {
                string Name = "";
                if (sender is IClientAPI)
                {
                    Name = ((IClientAPI)sender).Name;
                }
                c.From = Name;
                Sent   = neighborService.SendChatMessageToNeighbors(c, ChatSourceType.Agent, c.Scene.RegionInfo);
            }
            if (!Sent)
            {
                DeliverChatToAvatars(ChatSourceType.Agent, c);
            }
        }