• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ChatSourceType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ChatSourceType的典型用法代码示例。如果您正苦于以下问题:C# ChatSourceType类的具体用法?C# ChatSourceType怎么用?C# ChatSourceType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChatSourceType类属于命名空间,在下文中一共展示了ChatSourceType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Self_OnChat

 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);
     }
 }
开发者ID:RavenB,项目名称:gridsearch,代码行数:9,代码来源:Program.cs


示例2: ChatEventArgs

 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;
 }
开发者ID:SObS,项目名称:SLeek,代码行数:11,代码来源:ChatEventArgs.cs


示例3: Self_OnChat

        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);
            }
        }
开发者ID:santyr,项目名称:Futura-Testclient,代码行数:14,代码来源:Chat.cs


示例4: ProcessChat

 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);
 }
开发者ID:yooyke,项目名称:work,代码行数:14,代码来源:Protocol_process.cs


示例5: SendChatMessageToNeighbors

        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;
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:24,代码来源:LocalNeighborServiceConnector.cs


示例6: chatCallback

 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);
         }
     }
 }
开发者ID:caocao,项目名称:3di-viewer-rei,代码行数:17,代码来源:SLProtocol.cs


示例7: TrySendChatMessage

        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);
        }
开发者ID:JAllard,项目名称:Aurora-Sim,代码行数:25,代码来源:AuroraChatModule.cs


示例8: OnNetworkChat

 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);
 }
开发者ID:Booser,项目名称:radegast,代码行数:4,代码来源:Viewer.cs


示例9: DeliverChatToAvatars

        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);
        }
开发者ID:AkiraSonoda,项目名称:akisim,代码行数:73,代码来源:ChatModule.cs


示例10: DeliverChatToAvatars

        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);
                                       });
            }
        }
开发者ID:BogusCurry,项目名称:halcyon,代码行数:53,代码来源:ChatModule.cs


示例11: Self_OnChat

        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);
        }
开发者ID:SonicZentropy,项目名称:MiscProjects,代码行数:42,代码来源:CrawlerBot.cs


示例12: DeliverChatToAvatars

        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);
                    }
                }
            }
        }
开发者ID:NickyPerian,项目名称:Aurora,代码行数:100,代码来源:AuroraChatModule.cs


示例13: Add

        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);
        }
开发者ID:caocao,项目名称:3di-viewer-rei,代码行数:73,代码来源:ChatManager.cs


示例14: InformNeighborOfChatMessage

        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);
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:24,代码来源:NeighbourServiceConnector.cs


示例15: TrySendChatMessage

        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);
        }
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:24,代码来源:ChatModule.cs


示例16: Self_OnChat

		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);
		}
开发者ID:RavenB,项目名称:gridsearch,代码行数:6,代码来源:EchoMasterCommand.cs


示例17: TrySendChatMessage

        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);
        }
开发者ID:BogusCurry,项目名称:halcyon,代码行数:37,代码来源:ChatModule.cs


示例18: TrySendChatMessage

        /// <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;
        }
开发者ID:AkiraSonoda,项目名称:akisim,代码行数:49,代码来源:ChatModule.cs


示例19: DeliverChatToAvatars

        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);
        }
开发者ID:openmetaversefoundation,项目名称:fortis-opensim,代码行数:58,代码来源:ChatModule.cs


示例20: DeliverChatToAvatars

        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);
            }
        }
开发者ID:JAllard,项目名称:Aurora-Sim,代码行数:68,代码来源:AuroraChatModule.cs



注:本文中的ChatSourceType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ChatType类代码示例发布时间:2022-05-24
下一篇:
C# ChatMessage类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap