コード例 #1
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);
        }
コード例 #2
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);
             }
        }
コード例 #3
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;
        }
コード例 #4
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);
        }
コード例 #5
0
        public List <GridRegion> SendChatMessageToNeighbors(OSChatMessage message, ChatSourceType type, RegionInfo region, out bool RetVal)
        {
            RetVal = false;
            List <GridRegion> regionsNotified = new List <GridRegion>();

            if (!m_KnownNeighbors.ContainsKey(region.RegionID))
            {
                return(regionsNotified);
            }

            foreach (GridRegion neighbor in m_KnownNeighbors[region.RegionID])
            {
                if (neighbor.RegionID == region.RegionID)
                {
                    continue;
                }
                Scene scene = FindSceneByUUID(neighbor.RegionID);
                if (scene != null)
                {
                    Aurora.Framework.IChatModule chatModule = scene.RequestModuleInterface <Aurora.Framework.IChatModule>();
                    if (chatModule != null && !RetVal)
                    {
                        chatModule.DeliverChatToAvatars(type, message);
                        RetVal = true;
                    }
                    regionsNotified.Add(neighbor);
                }
            }
            return(regionsNotified);
        }
コード例 #6
0
        public bool SendChatMessageToNeighbors(OSChatMessage message, ChatSourceType type, RegionInfo region)
        {
            bool RetVal = false;

            if (!m_KnownNeighbors.ContainsKey(region.RegionID))
            {
                return(RetVal);
            }

            foreach (GridRegion neighbor in m_KnownNeighbors[region.RegionID])
            {
                if (neighbor.RegionID == region.RegionID)
                {
                    continue;
                }
                Scene scene = FindSceneByUUID(region.RegionID);
                if (scene != null)
                {
                    IChatModule chatModule = scene.RequestModuleInterface <IChatModule>();
                    if (chatModule != null && !RetVal)
                    {
                        chatModule.DeliverChatToAvatars(type, message);
                        RetVal = true;
                    }
                }
            }
            return(RetVal);
        }
コード例 #7
0
        protected void InformNeighborOfChatMessage(OSChatMessage message, ChatSourceType type, GridRegion region, RegionInfo thisRegion)
        {
            string uri = MakeUri(region, "/region/" + thisRegion.RegionID + "/");
            //m_log.Debug("   >>> DoHelloNeighbourCall <<< " + uri);

            // Fill it in
            Dictionary <string, object> args = new Dictionary <string, object>();

            try
            {
                args = Util.OSDToDictionary(thisRegion.PackRegionInfoData());
            }
            catch (Exception e)
            {
                m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message);
                return;
            }
            args["MESSAGE"] = WebUtils.BuildQueryString(message.ToKVP());
            args["TYPE"]    = (int)type;
            args["METHOD"]  = "inform_neighbors_of_chat_message";

            string queryString = WebUtils.BuildQueryString(args);

            SynchronousRestFormsRequester.MakeRequest("POST", uri, queryString);
        }
コード例 #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);
        }
コード例 #9
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);
        }
コード例 #10
0
        private byte[] InformNeighborsOfChatMessage(Dictionary <string, object> request)
        {
            byte[] result = new byte[0];

            if (!CheckThreatLevel(NeighborThreatLevel.Low))
            {
                return(result);
            }

            // retrieve the region
            RegionInfo aRegion = new RegionInfo();

            try
            {
                aRegion.UnpackRegionInfoData(Util.DictionaryToOSD(request));
            }
            catch (Exception)
            {
                return(result);
            }

            OSChatMessage message = new OSChatMessage();

            message.FromKVP(WebUtils.ParseQueryString(request["MESSAGE"].ToString()));
            ChatSourceType type = (ChatSourceType)int.Parse(request["TYPE"].ToString());

            if (m_AuthenticationService != null)
            {
                //Set password on the incoming region
                if (m_AuthenticationService.CheckExists(aRegion.RegionID))
                {
                    if (m_AuthenticationService.Authenticate(aRegion.RegionID, aRegion.Password.ToString(), 100) == "")
                    {
                        m_log.Warn("[RegionPostHandler]: Authentication failed for region " + aRegion.RegionName);
                        return(result);
                    }
                    else
                    {
                        m_log.InfoFormat("[RegionPostHandler]: Authentication succeeded for {0}", aRegion.RegionName);
                    }
                }
                else //Set the password then
                {
                    m_AuthenticationService.SetPasswordHashed(aRegion.RegionID, aRegion.Password.ToString());
                }
            }

            // Finally!
            m_NeighborService.SendChatMessageToNeighbors(message, type, aRegion);

            Dictionary <string, object> resp = new Dictionary <string, object>();

            resp["success"] = "true";

            string       xmlString = WebUtils.BuildXmlResponse(resp);
            UTF8Encoding encoding  = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
コード例 #11
0
 void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type,
                  ChatSourceType sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position)
 {
     if (message.Length > 0 && Client.MasterKey == id)
     {
         Client.Self.Chat(message, 0, ChatType.Normal);
     }
 }
コード例 #12
0
 void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type,
                  ChatSourceType sourcetype, string fromName, UUID id, UUID ownerid, Vector3 position)
 {
     if (message.Length > 0 && (Client.MasterKey == id || (Client.MasterName == fromName && !Client.AllowObjectMaster)))
     {
         Client.Self.Chat(message, 0, ChatType.Normal);
     }
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: RavenB/gridsearch
 static void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID id, UUID ownerid, Vector3 position)
 {
     if (fromName != _Client.Self.Name &&  type == ChatType.Normal && audible == ChatAudibleLevel.Fully)
     {
         string str = "<" + fromName + "> " + message;
         _IRC.SendMessage(_AutoJoinChannel, str);
         Console.WriteLine("[SL->IRC] " + str);
     }
 }
コード例 #14
0
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName  = c.From;
            UUID    fromID    = UUID.Zero;
            string  message   = c.Message;
            IScene  scene     = c.Scene;
            Vector3 fromPos   = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
                                            scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

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

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                if (!(scene is Scene))
                {
                    m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
                                     scene.RegionInfo.RegionName, c.Sender.AgentId);
                    return;
                }
                ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                fromPos  = avatar.AbsolutePosition;
                fromName = avatar.Name;
                fromID   = c.Sender.AgentId;

                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

            // m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);

            foreach (Scene s in m_scenes)
            {
                s.ForEachScenePresence(
                    delegate(ScenePresence presence)
                {
                    TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType);
                }
                    );
            }
        }
コード例 #15
0
ファイル: ChatEventArgs.cs プロジェクト: rcoscali/METAbolt
 public ChatEventArgs(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID id, UUID ownerid, Vector3 position)
 {
     this.message    = message;
     this.audible    = audible;
     this.type       = type;
     this.sourceType = sourceType;
     this.fromName   = fromName;
     this.id         = id;
     this.ownerid    = ownerid;
     this.position   = position;
 }
コード例 #16
0
ファイル: ChatEventArgs.cs プロジェクト: SObS/SLeek
 public ChatEventArgs(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position)
 {
     this.message = message;
     this.audible = audible;
     this.type = type;
     this.sourceType = sourceType;
     this.fromName = fromName;
     this.id = id;
     this.ownerid = ownerid;
     this.position = position;
 }
コード例 #17
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);
        }
コード例 #18
0
ファイル: Recorder.cs プロジェクト: Outworldz/waterwars
        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();
            }
        }
コード例 #19
0
ファイル: Chat.cs プロジェクト: santyr/Futura-Testclient
        public void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, 
            ChatSourceType sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position)
        {
            Console.WriteLine(fromName+":" + message);

            if (message.Length > 0 && message.ToLower().Contains(Client.Self.FirstName.ToLower()) && Client.Self.AgentID != id) {
                WebRequest request = WebRequest.Create("http://www.mr-technicl.com/slfutura.php?nick="+ fromName + "&message="+ message);
                WebResponse response = request.GetResponse();
                StreamReader input = new StreamReader(response.GetResponseStream());
                string say = input.ReadToEnd();
                input.Close();
                libsecondlife.Utilities.Realism.Chat(Client, say, ChatType.Normal, 25);
            }
        }
コード例 #20
0
ファイル: Protocol_process.cs プロジェクト: yooyke/work
 private void ProcessChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, OpenMetaverse.UUID id, OpenMetaverse.UUID ownerid, OpenMetaverse.Vector3 position)
 {
     string msg = JsonUtil.SerializeMessage(JsonType.ChatReceived, new JsonChatReceived(
         message,
         (int)type,
         fromName,
         id.ToString(),
         ownerid.ToString(),
         position.X,
         position.Y,
         position.Z
         ));
     Ox.EventFire(msg, true);
 }
コード例 #21
0
        void onChatMessageReceive(string message, ChatAudibleLevel audible, ChatType type,
                                  ChatSourceType sourceType, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position)
        {
            if ((message.Length != 0) && (message != null) && (message != String.Empty) && !(id == Self.AgentID))
            {
                Self.AutoPilotCancel();
                string[] sender = fromName.Split(' ');


                XmlRpcAgencyConnector.MethodName = "XmlRpcAgencyConnector.onChatMessageReceive";
                XmlRpcAgencyConnector.Params.Clear();
                XmlRpcAgencyConnector.Params.Add(agentName);
                XmlRpcAgencyConnector.Params.Add(message);
                XmlRpcAgencyConnector.Params.Add((int)position.X);
                XmlRpcAgencyConnector.Params.Add((int)position.Y);
                XmlRpcAgencyConnector.Params.Add((int)position.Z);
                XmlRpcAgencyConnector.Params.Add(sender[0]);
                XmlRpcAgencyConnector.Params.Add(sender[1]);

                try
                {
                        #if DEBUG
                    Console.WriteLine("Request: " + XmlRpcAgencyConnector);
                        #endif
                    XmlRpcResponse response = XmlRpcAgencyConnector.Send(XmlRpcAgencyConnectorUrl);
                        #if DEBUG
                    Console.WriteLine("Response: " + response);
                        #endif

                    if (response.IsFault)
                    {
                            #if DEBUG
                        Console.WriteLine("Fault {0}: {1}", response.FaultCode, response.FaultString);
                            #endif
                    }
                    else
                    {
                            #if DEBUG
                        Console.WriteLine("Returned: " + response.Value);
                            #endif
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception " + e);
                }
            }
        }
コード例 #22
0
 protected void InformNeighborsOfChatMessage(OSChatMessage message, ChatSourceType type, RegionInfo region, List <GridRegion> alreadyInformedRegions, List <GridRegion> neighbors)
 {
     lock (neighbors)
     {
         foreach (GridRegion neighbor in neighbors)
         {
             //If we have already informed the region, don't tell it again
             if (alreadyInformedRegions.Contains(neighbor))
             {
                 continue;
             }
             //Call the region then and add the regions it informed
             InformNeighborOfChatMessage(message, type, neighbor, region);
         }
     }
 }
コード例 #23
0
 void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID id, UUID ownerid, Vector3 position)
 {
     if (audible == ChatAudibleLevel.Fully && type != ChatType.StartTyping && type != ChatType.StopTyping)
     {
         Color color;
         if (sourceType == ChatSourceType.Agent)
         {
             color = Color.FromKnownColor(KnownColor.ControlText);
         }
         else
         {
             color = Color.FromKnownColor(KnownColor.GrayText);
         }
         LogChat(fromName, type, message, color);
     }
 }
コード例 #24
0
 public ListenEvent(ListenEvent le)
 {
     GlobalPosition = le.GlobalPosition;
     TargetID       = le.TargetID;
     Type           = le.Type;
     SourceType     = le.SourceType;
     Channel        = le.Channel;
     Name           = le.Name;
     ID             = le.ID;
     OwnerID        = le.OwnerID;
     Message        = le.Message;
     ButtonIndex    = le.ButtonIndex;
     OriginSceneID  = le.OriginSceneID;
     Distance       = le.Distance;
     Localization   = le.Localization;
     Group          = le.Group;
 }
コード例 #25
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);
        }
コード例 #26
0
        public virtual bool SendChatMessageToNeighbors(OSChatMessage message, ChatSourceType type, RegionInfo region)
        {
            bool RetVal = false;
            List <GridRegion> NotifiedRegions = m_LocalService.SendChatMessageToNeighbors(message, type, region, out RetVal);

            if (Neighbors.ContainsKey(region.RegionID))
            {
                int RegionsNotInformed = Neighbors[region.RegionID].Count - NotifiedRegions.Count;

                //We informed all of them locally, so quit early
                if (RegionsNotInformed == 0)
                {
                    return(RetVal);
                }

                //Now add the remote ones and tell it which ones have already been informed locally so that it doesn't inform them twice
                InformNeighborsOfChatMessage(message, type, region, NotifiedRegions, Neighbors[region.RegionID]);
            }
            //This tells the chat module whether we should send the message in the region it originated from, and if it
            return(RetVal);
        }
コード例 #27
0
        protected virtual void OnChatBroadcast(Object sender, OSChatMessage c)
        {
            // unless the chat to be broadcast is of type Region, we
            // drop it if its channel is neither 0 nor DEBUG_CHANNEL
            if (c.Channel != DEFAULT_CHANNEL && c.Channel != DEBUG_CHANNEL && c.Type != ChatTypeEnum.Region)
            {
                return;
            }

            ChatTypeEnum cType = c.Type;

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

            if (c.Range > m_maxChatDistance)
            {
                c.Range = m_maxChatDistance;
            }

            if (cType == ChatTypeEnum.SayTo)
            {
                //Change to something client can understand as SayTo doesn't exist except on the server
                cType = ChatTypeEnum.Owner;
            }

            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;
            ChatSourceType sourceType = ChatSourceType.Object;

            if (null != c.Sender)
            {
                IScenePresence avatar = c.Scene.GetScenePresence(c.Sender.AgentId);
                fromID     = c.Sender.AgentId;
                fromName   = avatar.Name;
                sourceType = ChatSourceType.Agent;
            }

            // MainConsole.Instance.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);

            c.Scene.ForEachScenePresence(
                delegate(IScenePresence presence)
            {
                // ignore chat from child agents
                if (presence.IsChildAgent)
                {
                    return;
                }

                IClientAPI client = presence.ControllingClient;

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

                // don't forward SayTo chat from objects to
                // non-targeted agents
                if ((c.Type == ChatTypeEnum.SayTo) &&
                    (c.ToAgentID != client.AgentId))
                {
                    return;
                }
                bool cached      = false;
                MuteList[] mutes = GetMutes(client.AgentId, out cached);
                foreach (MuteList m in mutes)
                {
                    if (m.MuteID == c.SenderUUID ||
                        (c.SenderObject != null && m.MuteID == c.SenderObject.ParentEntity.UUID))
                    {
                        return;
                    }
                }
                client.SendChatMessage(c.Message, (byte)cType,
                                       new Vector3(client.Scene.RegionInfo.RegionSizeX * 0.5f,
                                                   client.Scene.RegionInfo.RegionSizeY * 0.5f, 30), fromName,
                                       fromID,
                                       (byte)sourceType, (byte)ChatAudibleLevel.Fully);
            });
        }
コード例 #28
0
ファイル: EventManager.cs プロジェクト: CCIR/opensim
 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);
             }
         }
     }
 }
コード例 #29
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
 /// <summary>
 /// Construct a new instance of the ChatEventArgs object
 /// </summary>
 /// <param name="simulator">Sim from which the message originates</param>
 /// <param name="message">The message sent</param>
 /// <param name="audible">The audible level of the message</param>
 /// <param name="type">The type of message sent: whisper, shout, etc</param>
 /// <param name="sourceType">The source type of the message sender</param>
 /// <param name="fromName">The name of the agent or object sending the message</param>
 /// <param name="sourceId">The ID of the agent or object sending the message</param>
 /// <param name="ownerid">The ID of the object owner, or the agent ID sending the message</param>
 /// <param name="position">The position of the agent or object sending the message</param>
 public ChatEventArgs(Simulator simulator, string message, ChatAudibleLevel audible, ChatType type,
 ChatSourceType sourceType, string fromName, UUID sourceId, UUID ownerid, Vector3 position)
 {
     this.m_Simulator = simulator;
     this.m_Message = message;
     this.m_AudibleLevel = audible;
     this.m_Type = type;
     this.m_SourceType = sourceType;
     this.m_FromName = fromName;
     this.m_SourceID = sourceId;
     this.m_Position = position;
     this.m_OwnerID = ownerid;
 }
コード例 #30
0
ファイル: ChatModule.cs プロジェクト: lbgrid/opensim
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName  = c.From;
            UUID    fromID    = UUID.Zero;
            UUID    ownerID   = UUID.Zero;
            UUID    targetID  = c.TargetUUID;
            string  message   = c.Message;
            Scene   scene     = (Scene)c.Scene;
            Vector3 fromPos   = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
                                            scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

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

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                ScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId);
                fromPos  = avatar.AbsolutePosition;
                fromName = avatar.Name;
                fromID   = c.Sender.AgentId;
                ownerID  = c.Sender.AgentId;

                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
                {
                    ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
                }

                break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

//            m_log.DebugFormat(
//                "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}",
//                fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID);

            HashSet <UUID> receiverIDs = new HashSet <UUID>();

            if (targetID == UUID.Zero)
            {
                // This should use ForEachClient, but clients don't have a position.
                // If camera is moved into client, then camera position can be used
                scene.ForEachScenePresence(
                    delegate(ScenePresence presence)
                {
                    if (TrySendChatMessage(
                            presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false))
                    {
                        receiverIDs.Add(presence.UUID);
                    }
                }
                    );
            }
            else
            {
                // This is a send to a specific client eg from llRegionSayTo
                // no need to check distance etc, jand send is as say
                ScenePresence presence = scene.GetScenePresence(targetID);
                if (presence != null && !presence.IsChildAgent)
                {
                    if (TrySendChatMessage(
                            presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true))
                    {
                        receiverIDs.Add(presence.UUID);
                    }
                }
            }

            scene.EventManager.TriggerOnChatToClients(
                fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
        }
コード例 #31
0
ファイル: ChatManager.cs プロジェクト: caocao/3di-viewer-rei
        public void Add(string _message, ChatAudibleLevel _audible, ChatType _type, ChatSourceType _sourcetype, string _fromName, UUID _id, UUID _ownerid, Vector3 _position)
        {
            Reference.Log.Debug(_message + " ChatAudibleLevel:" + _audible.ToString() + " ChatType:" + _type.ToString() + " ChatSourceType:" + _sourcetype.ToString() + " FromName:" + _fromName);

            // name.
            string fromName = _fromName + ":";
            lock (messageHistory)
            {
                messageHistory.Add(fromName);
                Reference.Viewer.GuiManager.ChatAddMessage(fromName);
            }

            // message.
            string msg = _message;
            if (_message.Length > maxMessageLength)
            {
                string tail = "・・・";

                msg = _message.Substring(0, maxMessageLength - tail.Length);
                msg += tail;
            }

            // wide-char space -> 2 char space.
            msg = msg.Replace(" ", "  ");

            // trim space.
            msg = msg.Trim();

            List<int> colLen = new List<int>();
            int colMaxLen = 16 * 2;
            int lenCounter = 0;
            for (int i = 0; i < msg.Length; i++)
            {
                char c = msg[i];
                if (c < '!' || '~' < c)
                {
                    lenCounter += 2;
                }
                else
                {
                    lenCounter += 1;
                }

                if ((lenCounter >= colMaxLen) || ((i + 1) == msg.Length))
                {
                    colLen.Add(i + 1);
                    lenCounter = 0;
                }
            }

            List<string> msgList = new List<string>();
            for (int i = 0; i < colLen.Count; i++)
            {
                int start = (i > 0 ? colLen[i - 1] : 0);
                int length = (i > 0 ? colLen[i] - colLen[i - 1] : colLen[i]);

                string text = msg.Substring(start, length);
                msgList.Add(text);
            }

            for (int i = 0; i < msgList.Count; i++)
            {
                // message.
                string addMessage = "  " + msgList[i];
                lock (messageHistory)
                {
                    messageHistory.Add(addMessage);
                    Reference.Viewer.GuiManager.ChatAddMessage(addMessage);
                }
            }

            Reference.Viewer.Adapter.CallReceiveMessaged(_id.ToString(), _fromName, _message);
        }
コード例 #32
0
ファイル: ChatModule.cs プロジェクト: AkiraSonoda/akisim
        /// <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;
        }
コード例 #33
0
        public virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            UUID fromID = UUID.Zero;
            string message = c.Message;
            IScene scene = c.Scene;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = scene != null
                                    ? new Vector3(scene.RegionInfo.RegionLocX,
                                                  scene.RegionInfo.RegionLocY, 0)
                                    : Vector3.Zero;

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

            IScenePresence avatar = (scene != null && c.Sender != null)
                                        ? scene.GetScenePresence(c.Sender.AgentId)
                                        : null;
            switch (sourceType)
            {
                case ChatSourceType.Agent:
                    if (scene != null)
                    {
                        if (avatar != null && message == "")
                        {
                            fromPos = avatar.AbsolutePosition;
                            fromName = avatar.Name;
                            fromID = c.Sender.AgentId;
                            //Always send this so it fires on typing start and end
                            IAttachmentsModule attMod = scene.RequestModuleInterface<IAttachmentsModule>();
                            if (attMod != null)
                                attMod.SendScriptEventToAttachments(avatar.UUID, "changed", new object[] {Changed.STATE});
                        }
                        else
                            fromID = c.SenderUUID;
                    }
                    else
                        fromID = c.SenderUUID;
                    break;

                case ChatSourceType.Object:
                    fromID = c.SenderUUID;

                    break;
            }

            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

            // MainConsole.Instance.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);

            foreach (IScenePresence presence in from s in m_scenes
                                                select s.GetScenePresences() into ScenePresences
                                                from presence in ScenePresences
                                                where !presence.IsChildAgent
                                                let fromRegionPos = fromPos + regionPos
                                                let toRegionPos = presence.AbsolutePosition +
                                                                  new Vector3(presence.Scene.RegionInfo.RegionLocX,
                                                                              presence.Scene.RegionInfo.RegionLocY, 0)
                                                let dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos)
                                                where (c.Type != ChatTypeEnum.Whisper || dis <= m_whisperdistance) && (c.Type != ChatTypeEnum.Say || dis <= m_saydistance) && (c.Type != ChatTypeEnum.Shout || dis <= m_shoutdistance) && (c.Type != ChatTypeEnum.Custom || dis <= c.Range)
                                                where sourceType != ChatSourceType.Agent || avatar == null || avatar.CurrentParcel == null || (avatar.CurrentParcelUUID == presence.CurrentParcelUUID || (!avatar.CurrentParcel.LandData.Private && !presence.CurrentParcel.LandData.Private))
                                                select presence)
            {
                //If one of them is in a private parcel, and the other isn't in the same parcel, don't send the chat message
                TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType,
                                   c.Range);
            }
        }
コード例 #34
0
ファイル: Events.cs プロジェクト: myronjc/ajaxlife
        public void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position)
        {
            Hashtable item = new Hashtable();

            item.Add("MessageType", "SpatialChat");
            item.Add("Message", message);
            item.Add("Audible", audible);
            item.Add("Type", type);
            item.Add("SourceType", sourceType);
            item.Add("FromName", fromName);
            item.Add("ID", id);
            item.Add("OwnerID", ownerid);
            item.Add("Position", position);
            enqueue(item);
        }
コード例 #35
0
        public virtual void OnChatBroadcast(Object sender, OSChatMessage c)
        {
            // unless the chat to be broadcast is of type Region, we
            // drop it if its channel is neither 0 nor DEBUG_CHANNEL
            if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL && c.Type != ChatTypeEnum.Region)
            {
                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);

            ((Scene)c.Scene).ForEachScenePresence(
                delegate(ScenePresence presence)
            {
                // ignore chat from child agents
                if (presence.IsChildAgent)
                {
                    return;
                }

                IClientAPI client = presence.ControllingClient;

                // 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;
                }

                presence.Scene.EventManager.TriggerOnChatToClient(c.Message, fromID,
                                                                  client.AgentId, presence.Scene.RegionInfo.RegionID, (uint)Util.UnixTimeSinceEpoch(),
                                                                  ChatToClientType.InworldChat);

                client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, ownerID,
                                       (byte)sourceType, (byte)ChatAudibleLevel.Fully);
            });
        }
コード例 #36
0
        public virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName = c.From;
            UUID    fromID   = UUID.Zero;
            string  message  = c.Message;
            IScene  scene    = c.Scene;
            Vector3 fromPos  = c.Position;

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

            IScenePresence avatar = (scene != null && c.Sender != null)
                                        ? scene.GetScenePresence(c.Sender.AgentId)
                                        : null;

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                if (scene != null)
                {
                    if (avatar != null && message == "")
                    {
                        fromPos  = avatar.AbsolutePosition;
                        fromName = avatar.Name;
                        fromID   = c.Sender.AgentId;
                        //Always send this so it fires on typing start and end
                        IAttachmentsModule attMod = scene.RequestModuleInterface <IAttachmentsModule> ();
                        if (attMod != null)
                        {
                            attMod.SendScriptEventToAttachments(avatar.UUID, "changed", new object [] { Changed.STATE });
                        }
                    }
                    else
                    {
                        fromID = c.SenderUUID;
                    }
                }
                else
                {
                    fromID = c.SenderUUID;
                }
                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                break;
            }

            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

            // determine who should receive the message
            var presences     = m_Scene.GetScenePresences();
            var fromRegionPos = fromPos;

            foreach (IScenePresence presence in presences)
            {
                if (presence.IsChildAgent)
                {
                    continue;
                }

                // check presence distances
                var toRegionPos = presence.AbsolutePosition;
                var dis         = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);

                if (c.Type == ChatTypeEnum.Custom && dis > c.Range)                 // further than the defined custom range
                {
                    continue;
                }

                if (c.Type == ChatTypeEnum.Shout && dis > m_shoutdistance)          // too far for shouting
                {
                    continue;
                }

                if (c.Type == ChatTypeEnum.Say && dis > m_saydistance)              // too far for normal chat
                {
                    continue;
                }

                if (c.Type == ChatTypeEnum.Whisper && dis > m_whisperdistance)      // too far out for whisper
                {
                    continue;
                }

                if (sourceType == ChatSourceType.Agent)
                {
                    if (avatar != null)
                    {
                        if (avatar.CurrentParcel != null)
                        {
                            if (avatar.CurrentParcelUUID != presence.CurrentParcelUUID)     // not in the same parcel
                            {
                                continue;
                            }

                            // If both are not in the same private parcel, don't send the chat message
                            //                if (!(avatar.CurrentParcel.LandData.Private && presence.CurrentParcel.LandData.Private))
                            if (avatar.CurrentParcel.LandData.Private && !presence.CurrentParcel.LandData.Private)
                            {
                                continue;
                            }
                        }
                    }
                }

                // this one is good to go....
                TrySendChatMessage(presence, fromPos, fromID, fromName, c.Type, message, sourceType,
                                   c.Range);
            }

            /* previous for reference - remove when verified - greythane -
             * foreach (IScenePresence presence in from presence in m_Scene.GetScenePresences()
             *                                  where !presence.IsChildAgent
             *                                  let fromRegionPos = fromPos
             *                                  let toRegionPos = presence.AbsolutePosition
             *                                  let dis = (int) Util.GetDistanceTo(toRegionPos, fromRegionPos)
             *                                  where
             *                                      (c.Type != ChatTypeEnum.Whisper || dis <= m_whisperdistance) &&
             *                                      (c.Type != ChatTypeEnum.Say || dis <= m_saydistance) &&
             *                                      (c.Type != ChatTypeEnum.Shout || dis <= m_shoutdistance) &&
             *                                      (c.Type != ChatTypeEnum.Custom || dis <= c.Range)
             *                                  where
             *                                      sourceType != ChatSourceType.Agent || avatar == null ||
             *                                      avatar.CurrentParcel == null ||
             *                                      (avatar.CurrentParcelUUID == presence.CurrentParcelUUID ||
             *                                       (!avatar.CurrentParcel.LandData.Private &&
             *                                        !presence.CurrentParcel.LandData.Private))
             *                                  select presence)
             * {
             *  //If one of them is in a private parcel, and the other isn't in the same parcel, don't send the chat message
             *  TrySendChatMessage (presence, fromPos, fromID, fromName, c.Type, message, sourceType,
             *      c.Range);
             * }
             */
        }
コード例 #37
0
        static void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID id, UUID ownerid, Vector3 position)
        {
            if (id == client.Self.AgentID || message == "")
                return;

            if (message == "Claudius, go away.")
            {
                Disconnect();
                return;
            }

            if (message == "Claudius, info.")
            {
                string reply = fromName + ", your id is '" + id + ", your ownerId is '" + ownerid +
                               ", and your location is '" + position + ".";
                client.Self.Chat(reply, 0, ChatType.Normal);
                client.Self.Chat("Mine is " + client.Self.SimPosition + ".", 0, ChatType.Normal);
                return;
            }

            if (message == "Claudius, come here.")
            {
                Console.WriteLine("About to follow");
                /*
                client.Self.AutoPilotLocal(Convert.ToInt32(position.X), Convert.ToInt32(position.Y), position.Z);
                Console.WriteLine("Going to: " + position );
                 */

                GoToPosition(position);

                return;
            }

            if (message.StartsWith("Claudius, go to:"))
            {
                String dest = message.Substring(message.IndexOf(':') + 1);
                List<Vector3> wayPointList = WaypointService.GetWayPoints(client.Self.SimPosition, dest);
                TraverseWayPoints(wayPointList);
                return;
            }
            client.Self.Chat(message, 0, ChatType.Normal);
        }
コード例 #38
0
        public virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName  = c.From;
            UUID    fromID    = UUID.Zero;
            string  message   = c.Message;
            IScene  scene     = c.Scene;
            Vector3 fromPos   = c.Position;
            Vector3 regionPos = scene != null ? new Vector3(scene.RegionInfo.RegionLocX,
                                                            scene.RegionInfo.RegionLocY, 0) : Vector3.Zero;

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

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                if (scene != null)
                {
                    if (!(scene is Scene))
                    {
                        m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
                                         scene.RegionInfo.RegionName, c.Sender.AgentId);
                        return;
                    }
                    IScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                    if (avatar != null && message == "")
                    {
                        fromPos  = avatar.AbsolutePosition;
                        fromName = avatar.Name;
                        fromID   = c.Sender.AgentId;
                        //Always send this so it fires on typing start and end
                        IAttachmentsModule attMod = scene.RequestModuleInterface <IAttachmentsModule>();
                        if (attMod != null)
                        {
                            attMod.SendScriptEventToAttachments(avatar.UUID, "changed", new object[] { Changed.STATE });
                        }
                    }
                    else
                    {
                        fromID = c.SenderUUID;
                    }
                }
                else
                {
                    fromID = c.SenderUUID;
                }
                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                break;
            }

            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

            // m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);

            foreach (Scene s in m_scenes)
            {
                List <IScenePresence> ScenePresences = s.GetScenePresences();
                foreach (IScenePresence presence in ScenePresences)
                {
                    // don't send stuff to child agents
                    if (!presence.IsChildAgent)
                    {
                        //Block this out early so we don't look through the mutes if the message shouldn't even be sent
                        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);

                        //Check for max range
                        if (c.Type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                            c.Type == ChatTypeEnum.Say && dis > m_saydistance ||
                            c.Type == ChatTypeEnum.Shout && dis > m_shoutdistance ||
                            c.Type == ChatTypeEnum.Custom && dis > c.Range)
                        {
                            continue;
                        }
                        TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, c.Range);
                    }
                }
            }
        }
コード例 #39
0
        public bool SendChatMessageToNeighbors(OSChatMessage message, ChatSourceType type, RegionInfo region)
        {
            bool RetVal = false;

            if (!m_KnownNeighbors.ContainsKey(region.RegionID))
                return RetVal;

            foreach (GridRegion neighbor in m_KnownNeighbors[region.RegionID])
            {
                if (neighbor.RegionID == region.RegionID)
                    continue;
                Scene scene = FindSceneByUUID(region.RegionID);
                if (scene != null)
                {
                    IChatModule chatModule = scene.RequestModuleInterface<IChatModule>();
                    if (chatModule != null && !RetVal)
                    {
                        chatModule.DeliverChatToAvatars(type, message);
                        RetVal = true;
                    }
                }
            }
            return RetVal;
        }
コード例 #40
0
		void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, 
            ChatSourceType sourcetype, string fromName, Guid id, Guid ownerid, Vector3 position)
		{
			if (message.Length > 0 && (Client.MasterKey == id || (Client.MasterName == fromName && !Client.AllowObjectMaster)))
			    Client.Self.Chat(message, 0, ChatType.Normal);
		}
コード例 #41
0
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            UUID fromID = UUID.Zero;
            string message = c.Message;
            IScene scene = c.Scene;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
                                            scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

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

            switch (sourceType)
            {
                case ChatSourceType.Agent:
                    if (!(scene is Scene))
                    {
                        m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
                                         scene.RegionInfo.RegionName, c.Sender.AgentId);
                        return;
                    }
                    ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                    fromPos = avatar.AbsolutePosition;
                    fromName = avatar.Name;
                    fromID = c.Sender.AgentId;
                    //Always send this so it fires on typing start and end
                    avatar.SendScriptEventToAttachments("changed", new object[] { Changed.STATE });

                    break;

                case ChatSourceType.Object:
                    fromID = c.SenderUUID;

                    break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

            // m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);

            foreach (Scene s in m_scenes)
            {
                List<ScenePresence> ScenePresences = s.ScenePresences;
                foreach (ScenePresence presence in ScenePresences)
                {
                    // don't send stuff to child agents
                    if (!presence.IsChildAgent)
                    {
                        //Block this out early so we don't look through the mutes if the message shouldn't even be sent
                        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);

                        //Check for max range
                        if (c.Type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                            c.Type == ChatTypeEnum.Say && dis > m_saydistance ||
                            c.Type == ChatTypeEnum.Shout && dis > m_shoutdistance ||
                            c.Type == ChatTypeEnum.Custom && dis > c.Range)
                        {
                            continue;
                        }
                        //The client actually does this on its own, we don't need to
                        /*//Check whether the user is muted
                        bool IsMuted = false;
                        if (message != "" && m_useMuteListModule)
                        {
                            Dictionary<UUID, bool> cache = new Dictionary<UUID,bool>();
                            //Check the cache first so that we don't kill the server
                            if (IsMutedCache.TryGetValue(presence.UUID, out cache))
                            {
                                //If the cache doesn't contain the person, they arn't used
                                if (!cache.TryGetValue(fromID, out IsMuted))
                                {
                                    cache[fromID] = IsMuted = false;
                                }
                            }
                            else
                            {
                                cache = new Dictionary<UUID, bool>();
                                //This loads all mutes into the list
                                MuteList[] List = MuteListConnector.GetMuteList(presence.UUID);
                                foreach (MuteList mute in List)
                                {
                                    cache[mute.MuteID] = true;
                                }
                                IsMutedCache[presence.UUID] = cache;
                            }
                        }
                        if (!IsMuted)
                            */
                        TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, c.Range);
                    }
                }
            }
        }
コード例 #42
0
ファイル: ChatModule.cs プロジェクト: AkiraSonoda/akisim
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            UUID fromID = UUID.Zero;
            UUID ownerID = UUID.Zero;
            UUID targetID = c.TargetUUID;
            string message = c.Message;
            Scene scene = (Scene)c.Scene;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
                                            scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

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

            switch (sourceType) 
            {
            case ChatSourceType.Agent:
                ScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId);
                fromPos = avatar.AbsolutePosition;
                fromName = avatar.Name;
                fromID = c.Sender.AgentId;
                ownerID = c.Sender.AgentId;

                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
                    ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;

                break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

//            m_log.DebugFormat(
//                "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}",
//                fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID);

            HashSet<UUID> receiverIDs = new HashSet<UUID>();

            if (targetID == UUID.Zero)
            {
                // This should use ForEachClient, but clients don't have a position.
                // If camera is moved into client, then camera position can be used
                scene.ForEachScenePresence(
                    delegate(ScenePresence presence)
                    {
                        if (TrySendChatMessage(
                            presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false))
                            receiverIDs.Add(presence.UUID);
                    }
                );
            }
            else
            {
                // This is a send to a specific client eg from llRegionSayTo
                // no need to check distance etc, jand send is as say
                ScenePresence presence = scene.GetScenePresence(targetID);
                if (presence != null && !presence.IsChildAgent)
                {
                    if (TrySendChatMessage(
                        presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true))
                        receiverIDs.Add(presence.UUID);
                }
            }

            scene.EventManager.TriggerOnChatToClients(
                fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
        }
コード例 #43
0
ファイル: AuroraChatModule.cs プロジェクト: KSLcom/Aurora-Sim
        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);
        }
コード例 #44
0
ファイル: Viewer.cs プロジェクト: Booser/radegast
 private void OnNetworkChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype, string fromName, UUID id, UUID ownerid, Vector3 position)
 {
     UserInterface.OnNetworkChat(message, audible, type, sourcetype, fromName, id, ownerid, position);
 }
コード例 #45
0
ファイル: AuroraChatModule.cs プロジェクト: rknop/Aurora-Sim
        public virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            UUID fromID = UUID.Zero;
            string message = c.Message;
            IScene scene = c.Scene;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = scene != null ? new Vector3(scene.RegionInfo.RegionLocX,
                                            scene.RegionInfo.RegionLocY, 0) : Vector3.Zero;

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

            switch (sourceType)
            {
                case ChatSourceType.Agent:
                    if (scene != null)
                    {
                        if (!(scene is Scene))
                        {
                            m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
                                             scene.RegionInfo.RegionName, c.Sender.AgentId);
                            return;
                        }
                        IScenePresence avatar = scene.GetScenePresence (c.Sender.AgentId);
                        if (avatar != null && message == "")
                        {
                            fromPos = avatar.AbsolutePosition;
                            fromName = avatar.Name;
                            fromID = c.Sender.AgentId;
                            //Always send this so it fires on typing start and end
                            IAttachmentsModule attMod = scene.RequestModuleInterface<IAttachmentsModule>();
                            if(attMod != null)
                                attMod.SendScriptEventToAttachments(avatar.UUID, "changed", new object[] { Changed.STATE });
                        }
                        else
                            fromID = c.SenderUUID;
                    }
                    else
                        fromID = c.SenderUUID;
                    break;

                case ChatSourceType.Object:
                    fromID = c.SenderUUID;

                    break;
            }

            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

            // m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);

            foreach (Scene s in m_scenes)
            {
                List<IScenePresence> ScenePresences = s.GetScenePresences ();
                foreach (IScenePresence presence in ScenePresences)
                {
                    // don't send stuff to child agents
                    if (!presence.IsChildAgent)
                    {
                        //Block this out early so we don't look through the mutes if the message shouldn't even be sent
                        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);

                        //Check for max range
                        if (c.Type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                            c.Type == ChatTypeEnum.Say && dis > m_saydistance ||
                            c.Type == ChatTypeEnum.Shout && dis > m_shoutdistance ||
                            c.Type == ChatTypeEnum.Custom && dis > c.Range)
                        {
                            continue;
                        }
                        TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, c.Range);
                    }
                }
            }
        }
コード例 #46
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);
        }
コード例 #47
0
ファイル: ChatModule.cs プロジェクト: CassieEllen/opensim
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            string fromNamePrefix = "";
            UUID fromID = UUID.Zero;
            UUID ownerID = UUID.Zero;
            string message = c.Message;
            IScene scene = c.Scene;
            UUID destination = c.Destination;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);

            bool checkParcelHide = false;
            UUID sourceParcelID = UUID.Zero;
            Vector3 hidePos = fromPos;

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

            switch (sourceType) 
            {
            case ChatSourceType.Agent:
                if (!(scene is Scene))
                {
                    m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
                                     scene.RegionInfo.RegionName, c.Sender.AgentId);
                    return;
                }
                ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                fromPos = avatar.AbsolutePosition;
                fromName = avatar.Name;
                fromID = c.Sender.AgentId;
                if (avatar.GodLevel >= 200)
                { // let gods speak to outside or things may get confusing
                    fromNamePrefix = m_adminPrefix;
                    checkParcelHide = false;
                }
                else
                {
                    checkParcelHide = true;
                }
                destination = UUID.Zero; // Avatars cant "SayTo"
                ownerID = c.Sender.AgentId;
                
                hidePos = fromPos;
                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
                {
                    ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
                    if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
                    {
                        checkParcelHide = true;
                        hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
                    }
                }
                break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

//            m_log.DebugFormat(
//                "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", 
//                fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);

            HashSet<UUID> receiverIDs = new HashSet<UUID>();

            if (checkParcelHide)
            {
                checkParcelHide = false;
                if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
                {
                    ILandObject srcland = (scene as Scene).LandChannel.GetLandObject(hidePos.X, hidePos.Y);
                    if (srcland != null && !srcland.LandData.SeeAVs)
                    {
                        sourceParcelID = srcland.LandData.GlobalID;
                        checkParcelHide = true;
                    }
                }
            }

            foreach (Scene s in m_scenes)
            {
                // This should use ForEachClient, but clients don't have a position.
                // If camera is moved into client, then camera position can be used
                // MT: No, it can't, as chat is heard from the avatar position, not
                // the camera position.

                s.ForEachScenePresence(
                    delegate(ScenePresence presence)
                    {
                        if (destination != UUID.Zero && presence.UUID != destination)
                            return;
                        ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
                        if (Presencecheck != null)
                        {
                            // This will pass all chat from objects. Not
                            // perfect, but it will do. For now. Better
                            // than the prior behavior of muting all
                            // objects on a parcel with access restrictions
                            if (checkParcelHide)
                            {
                                if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200)
                                    return;
                            }
                            if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
                            {
                                if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                            ownerID, fromNamePrefix + fromName, c.Type,
                                            message, sourceType, (destination != UUID.Zero)))
                                    receiverIDs.Add(presence.UUID);
                            }
                        }
                        else if(!checkParcelHide && (presence.IsChildAgent))
                        {
                            if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                            ownerID, fromNamePrefix + fromName, c.Type,
                                            message, sourceType, (destination != UUID.Zero)))
                                receiverIDs.Add(presence.UUID);
                        }
                    }
                );
            }
            
            (scene as Scene).EventManager.TriggerOnChatToClients(
                fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
        }
コード例 #48
0
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            string fromNamePrefix = "";
            UUID fromID = UUID.Zero;
            UUID ownerID = UUID.Zero;
            string message = c.Message;
            Scene scene = c.Scene as Scene;
            UUID destination = c.Destination;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);

            bool checkParcelHide = false;
            UUID sourceParcelID = UUID.Zero;
            Vector3 hidePos = fromPos;

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

            if(!m_scenes.Contains(scene))
            {
                m_log.WarnFormat("[CHAT]: message from unkown scene {0} ignored",
                                     scene.RegionInfo.RegionName);
                return;
            }

            switch (sourceType)
            {
                case ChatSourceType.Agent:
                    ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                    fromPos = avatar.AbsolutePosition;
                    fromName = avatar.Name;
                    fromID = c.Sender.AgentId;
                    if (avatar.IsViewerUIGod)
                    { // let gods speak to outside or things may get confusing
                        fromNamePrefix = m_adminPrefix;
                        checkParcelHide = false;
                    }
                    else
                    {
                        checkParcelHide = true;
                    }
                    destination = UUID.Zero; // Avatars cant "SayTo"
                    ownerID = c.Sender.AgentId;

                    hidePos = fromPos;
                    break;

                case ChatSourceType.Object:
                    fromID = c.SenderUUID;

                    if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
                    {
                        ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
                        if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
                        {
                            checkParcelHide = true;
                            hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
                        }
                    }
                    break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

//            m_log.DebugFormat(
//                "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
//                fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);

            HashSet<UUID> receiverIDs = new HashSet<UUID>();

            if (checkParcelHide)
            {
                checkParcelHide = false;
                if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
                {
                    ILandObject srcland = scene.LandChannel.GetLandObject(hidePos.X, hidePos.Y);
                    if (srcland != null && !srcland.LandData.SeeAVs)
                    {
                        sourceParcelID = srcland.LandData.GlobalID;
                        checkParcelHide = true;
                    }
                }
            }

            scene.ForEachScenePresence(
                delegate(ScenePresence presence)
                {
                    if (destination != UUID.Zero && presence.UUID != destination)
                        return;

                    if(presence.IsChildAgent)
                        {
                            if(checkParcelHide)
                                return;
                            if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                        ownerID, fromNamePrefix + fromName, c.Type,
                                        message, sourceType, (destination != UUID.Zero)))
                                receiverIDs.Add(presence.UUID);
                            return;
                        }

                    ILandObject Presencecheck = scene.LandChannel.GetLandObject(presence.AbsolutePosition.X,            presence.AbsolutePosition.Y);
                    if (Presencecheck != null)
                    {
                        if (checkParcelHide)
                        {
                            if (sourceParcelID != Presencecheck.LandData.GlobalID && !presence.IsViewerUIGod)
                                return;
                        }
                        if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
                        {
                            if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                        ownerID, fromNamePrefix + fromName, c.Type,
                                        message, sourceType, (destination != UUID.Zero)))
                                receiverIDs.Add(presence.UUID);
                        }
                    }
                });

            scene.EventManager.TriggerOnChatToClients(
                fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
        }
コード例 #49
0
		void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, 
            ChatSourceType sourcetype, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position)
		{
			if (message.Length > 0 && Client.MasterKey == id)
			    Client.Self.Chat(message, 0, ChatType.Normal);
		}
コード例 #50
0
        protected void InformNeighborOfChatMessage(OSChatMessage message, ChatSourceType type, GridRegion region, RegionInfo thisRegion)
        {
            string uri = MakeUri(region, "/region/" + thisRegion.RegionID + "/");
            //m_log.Debug("   >>> DoHelloNeighbourCall <<< " + uri);

            // Fill it in
            Dictionary<string, object> args = new Dictionary<string, object>();

            try
            {
                args = Util.OSDToDictionary(thisRegion.PackRegionInfoData());
            }
            catch (Exception e)
            {
                m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message);
                return;
            }
            args["MESSAGE"] = WebUtils.BuildQueryString(message.ToKVP());
            args["TYPE"] = (int)type;
            args["METHOD"] = "inform_neighbors_of_chat_message";

            string queryString = WebUtils.BuildQueryString(args);
            SynchronousRestFormsRequester.MakeRequest("POST", uri, queryString);
        }
コード例 #51
0
ファイル: ChatModule.cs プロジェクト: savino1976/Aurora-Sim
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            UUID fromID = UUID.Zero;
            string message = c.Message;
            IScene scene = c.Scene;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX,
                                            scene.RegionInfo.RegionLocY, 0);

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

            switch (sourceType)
            {
                case ChatSourceType.Agent:
                    IScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId);
                    fromPos = avatar.AbsolutePosition;
                    fromName = avatar.Name;
                    fromID = c.Sender.AgentId;

                    break;

                case ChatSourceType.Object:
                    fromID = c.SenderUUID;

                    break;
            }

            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

            // MainConsole.Instance.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);

            foreach (IScene s in m_scenes)
            {
#if (!ISWIN)
                s.ForEachScenePresence(
                    delegate(IScenePresence presence)
                    {
                        TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType);
                    }
                );
#else
                s.ForEachScenePresence(
                    presence => TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message,
                                                   sourceType)
                    );
#endif
            }
        }
コード例 #52
0
ファイル: SLProtocol.cs プロジェクト: caocao/3di-viewer-rei
 private void chatCallback(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype,
                           string fromName, UUID id, UUID ownerid, Vector3 position)
 {
     // This is weird -- we get start/stop typing chats from
     // other avatars, and we get messages back that we sent.
     // (Tested on OpenSim r3187)
     // So we explicitly check for those cases here.
     if ((int)type < 4 && id != m_user.Self.AgentID)
     {
         m_log.Debug("Chat: " + fromName + ": " + message);
         if (OnChat != null)
         {
             OnChat(message, audible, type, sourcetype,
                               fromName, id, ownerid, position);
         }
     }
 }
コード例 #53
0
ファイル: ChatModule.cs プロジェクト: savino1976/Aurora-Sim
        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);
        }
コード例 #54
0
ファイル: ChatModule.cs プロジェクト: BogusCurry/halcyon
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            UUID fromID = UUID.Zero;
            UUID destID = c.DestinationUUID;
            string message = c.Message;
            IScene scene = c.Scene;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
                                            scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

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

            switch (sourceType) 
            {
            case ChatSourceType.Agent:
                if (!(scene is Scene))
                {
                    m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
                                     scene.RegionInfo.RegionName, c.Sender.AgentId);
                    return;
                }
                ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                fromPos = avatar.AbsolutePosition;
                fromName = avatar.Name;
                fromID = c.Sender.AgentId;

                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

            // m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);

            foreach (Scene s in m_scenes)
            {
                s.ForEachScenePresence(delegate(ScenePresence presence) 
                                       {
                                           
                                           if (!presence.IsChildAgent)
                                               if ((destID == UUID.Zero) || (destID == presence.UUID))
                                                    TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, 
                                                              c.Type, message, sourceType);
                                       });
            }
        }
コード例 #55
0
        public virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName = c.From;
            UUID    fromID   = UUID.Zero;
            string  message  = c.Message;
            IScene  scene    = c.Scene;
            Vector3 fromPos  = c.Position;

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

            IScenePresence avatar = (scene != null && c.Sender != null)
                                        ? scene.GetScenePresence(c.Sender.AgentId)
                                        : null;

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                if (scene != null)
                {
                    if (avatar != null && message == "")
                    {
                        fromPos  = avatar.AbsolutePosition;
                        fromName = avatar.Name;
                        fromID   = c.Sender.AgentId;
                        //Always send this so it fires on typing start and end
                        IAttachmentsModule attMod = scene.RequestModuleInterface <IAttachmentsModule>();
                        if (attMod != null)
                        {
                            attMod.SendScriptEventToAttachments(avatar.UUID, "changed", new object[] { Changed.STATE });
                        }
                    }
                    else
                    {
                        fromID = c.SenderUUID;
                    }
                }
                else
                {
                    fromID = c.SenderUUID;
                }
                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                break;
            }

            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

            foreach (IScenePresence presence in from presence in m_Scene.GetScenePresences()
                     where !presence.IsChildAgent
                     let fromRegionPos = fromPos
                                         let toRegionPos = presence.AbsolutePosition
                                                           let dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos)
                                                                     where
                                                                     (c.Type != ChatTypeEnum.Whisper || dis <= m_whisperdistance) &&
                                                                     (c.Type != ChatTypeEnum.Say || dis <= m_saydistance) &&
                                                                     (c.Type != ChatTypeEnum.Shout || dis <= m_shoutdistance) &&
                                                                     (c.Type != ChatTypeEnum.Custom || dis <= c.Range)
                                                                     where
                                                                     sourceType != ChatSourceType.Agent || avatar == null ||
                                                                     avatar.CurrentParcel == null ||
                                                                     (avatar.CurrentParcelUUID == presence.CurrentParcelUUID ||
                                                                      (!avatar.CurrentParcel.LandData.Private &&
                                                                       !presence.CurrentParcel.LandData.Private))
                                                                     select presence)
            {
                //If one of them is in a private parcel, and the other isn't in the same parcel, don't send the chat message
                TrySendChatMessage(presence, fromPos, fromID, fromName, c.Type, message, sourceType,
                                   c.Range);
            }
        }
コード例 #56
0
        public List<GridRegion> SendChatMessageToNeighbors(OSChatMessage message, ChatSourceType type, RegionInfo region, out bool RetVal)
        {
            RetVal = false;
            List<GridRegion> regionsNotified = new List<GridRegion>();

            if (!m_KnownNeighbors.ContainsKey(region.RegionID))
                return regionsNotified;

            foreach (GridRegion neighbor in m_KnownNeighbors[region.RegionID])
            {
                if (neighbor.RegionID == region.RegionID)
                    continue;
                Scene scene = FindSceneByUUID(neighbor.RegionID);
                if (scene != null)
                {
                    Aurora.Framework.IChatModule chatModule = scene.RequestModuleInterface<Aurora.Framework.IChatModule>();
                    if (chatModule != null && !RetVal)
                    {
                        chatModule.DeliverChatToAvatars(type, message);
                        RetVal = true;
                    }
                    regionsNotified.Add(neighbor);
                }
            }
            return regionsNotified;
        }
コード例 #57
0
ファイル: ChatModule.cs プロジェクト: BogusCurry/halcyon
        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);
        }
コード例 #58
0
ファイル: LocalChat.cs プロジェクト: RavenB/gridsearch
 void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID id, UUID ownerid, Vector3 position)
 {
     if (audible == ChatAudibleLevel.Fully && type != ChatType.StartTyping && type != ChatType.StopTyping)
     {
         Color color;
         if (sourceType == ChatSourceType.Agent) color = Color.FromKnownColor(KnownColor.ControlText);
         else color = Color.FromKnownColor(KnownColor.GrayText);
         LogChat(fromName, type, message, color);
     }
 }
コード例 #59
0
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            UUID fromID = UUID.Zero;
            string message = c.Message;
            IScene scene = c.Scene;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
                                            scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);

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

            switch (sourceType) 
            {
            case ChatSourceType.Agent:
                if (!(scene is Scene))
                {
                    m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
                                     scene.RegionInfo.RegionName, c.Sender.AgentId);
                    return;
                }
                ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                fromPos = avatar.AbsolutePosition;
                fromName = avatar.Name;
                fromID = c.Sender.AgentId;

                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

//            m_log.DebugFormat(
//                "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", 
//                fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);

            HashSet<UUID> receiverIDs = new HashSet<UUID>();
            
            foreach (Scene s in m_scenes)
            {
                s.ForEachScenePresence(
                    delegate(ScenePresence presence)
                    {
                        if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType))
                            receiverIDs.Add(presence.UUID);
                    }
                );
            }
            
            (scene as Scene).EventManager.TriggerOnChatToClients(
                fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
        }