当前位置: 首页>>代码示例>>C#>>正文


C# UserAgentServiceConnector.StatusNotification方法代码示例

本文整理汇总了C#中OpenSim.Services.Connectors.Hypergrid.UserAgentServiceConnector.StatusNotification方法的典型用法代码示例。如果您正苦于以下问题:C# UserAgentServiceConnector.StatusNotification方法的具体用法?C# UserAgentServiceConnector.StatusNotification怎么用?C# UserAgentServiceConnector.StatusNotification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSim.Services.Connectors.Hypergrid.UserAgentServiceConnector的用法示例。


在下文中一共展示了UserAgentServiceConnector.StatusNotification方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StatusNotify


//.........这里部分代码省略.........
        //private void CollectOnlineFriendsElsewhere(UUID userID, List<string> foreignFriends)
        //{
        //    // let's divide the friends on a per-domain basis
        //    Dictionary<string, List<string>> friendsPerDomain = new Dictionary<string, List<string>>();
        //    foreach (string friend in foreignFriends)
        //    {
        //        UUID friendID;
        //        if (!UUID.TryParse(friend, out friendID))
        //        {
        //            // it's a foreign friend
        //            string url = string.Empty, tmp = string.Empty;
        //            if (Util.ParseUniversalUserIdentifier(friend, out friendID, out url, out tmp, out tmp, out tmp))
        //            {
        //                if (!friendsPerDomain.ContainsKey(url))
        //                    friendsPerDomain[url] = new List<string>();
        //                friendsPerDomain[url].Add(friend);
        //            }
        //        }
        //    }

        //    // Now, call those worlds
            
        //    foreach (KeyValuePair<string, List<string>> kvp in friendsPerDomain)
        //    {
        //        List<string> ids = new List<string>();
        //        foreach (string f in kvp.Value)
        //            ids.Add(f);
        //        UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key);
        //        List<UUID> online = uConn.GetOnlineFriends(userID, ids);
        //        // Finally send the notifications to the user
        //        // this whole process may take a while, so let's check at every
        //        // iteration that the user is still here
        //        IClientAPI client = LocateClientObject(userID);
        //        if (client != null)
        //            client.SendAgentOnline(online.ToArray());
        //        else
        //            break;
        //    }

        //}

        protected override void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online)
        {
//            m_log.DebugFormat("[HGFRIENDS MODULE]: Entering StatusNotify for {0}", userID);

            // First, let's divide the friends on a per-domain basis
            Dictionary<string, List<FriendInfo>> friendsPerDomain = new Dictionary<string, List<FriendInfo>>();
            foreach (FriendInfo friend in friendList)
            {
                UUID friendID;
                if (UUID.TryParse(friend.Friend, out friendID))
                {
                    if (!friendsPerDomain.ContainsKey("local"))
                        friendsPerDomain["local"] = new List<FriendInfo>();
                    friendsPerDomain["local"].Add(friend);
                }
                else
                {
                    // it's a foreign friend
                    string url = string.Empty, tmp = string.Empty;
                    if (Util.ParseUniversalUserIdentifier(friend.Friend, out friendID, out url, out tmp, out tmp, out tmp))
                    {
                        // Let's try our luck in the local sim. Who knows, maybe it's here
                        if (LocalStatusNotification(userID, friendID, online))
                            continue;

                        if (!friendsPerDomain.ContainsKey(url))
                            friendsPerDomain[url] = new List<FriendInfo>();
                        friendsPerDomain[url].Add(friend);
                    }
                }
            }

            // For the local friends, just call the base method
            // Let's do this first of all
            if (friendsPerDomain.ContainsKey("local"))
                base.StatusNotify(friendsPerDomain["local"], userID, online);

            foreach (KeyValuePair<string, List<FriendInfo>> kvp in friendsPerDomain)
            {
                if (kvp.Key != "local")
                {
                    // For the others, call the user agent service 
                    List<string> ids = new List<string>();
                    foreach (FriendInfo f in kvp.Value)
                        ids.Add(f.Friend);
                    UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key);
                    List<UUID> friendsOnline = uConn.StatusNotification(ids, userID, online);

                    if (online && friendsOnline.Count > 0)
                    {
                        IClientAPI client = LocateClientObject(userID);
                        if (client != null)
                            client.SendAgentOnline(friendsOnline.ToArray());
                    }
                }
            }

//            m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting StatusNotify for {0}", userID);
        }
开发者ID:JamesStallings,项目名称:Ubit-opensim,代码行数:101,代码来源:HGFriendsModule.cs


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