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


C# IClientAPI.SendAgentOnline方法代码示例

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


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

示例1: OnApproveFriendRequest

        private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
        {
            FriendsService.StoreFriend(agentID, friendID.ToString(), 1);
            FriendsService.StoreFriend(friendID, agentID.ToString(), 1);
            // update the local cache
            m_Friends[agentID].Friends = FriendsService.GetFriends(agentID);

            m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);

            //
            // Notify the friend
            //

            // Try Local
            if (LocalFriendshipApproved(agentID, client.Name, friendID))
            {
                client.SendAgentOnline(new UUID[] { friendID });
                return;
            }

            // The friend is not here
            PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
            PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
            if (friendSession != null)
            {
                GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
                m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID);
                client.SendAgentOnline(new UUID[] { friendID });
            }

        }
开发者ID:gumho,项目名称:diva-distribution,代码行数:31,代码来源:FriendsModule.cs

示例2: LocalFriendshipApproved

        public bool LocalFriendshipApproved(UUID userID, string name, IClientAPI us, UUID friendID)
        {
            IClientAPI friendClient = LocateClientObject(friendID);
            if (friendClient != null)
            {
                //They are online, send the online message
                if (us != null)
                    us.SendAgentOnline(new[] {friendID});

                // the prospective friend in this sim as root agent
                GridInstantMessage im = new GridInstantMessage(m_Scenes[0], userID, name, friendID,
                                                               (byte) InstantMessageDialog.FriendshipAccepted,
                                                               userID.ToString(), false, Vector3.Zero);
                friendClient.SendInstantMessage(im);

                // Update the local cache
                UpdateFriendsCache(friendID);


                //
                // put a calling card into the inventory of the friend
                //
                ICallingCardModule ccmodule = friendClient.Scene.RequestModuleInterface<ICallingCardModule>();
                if (ccmodule != null)
                {
                    UserAccount account = friendClient.Scene.UserAccountService.GetUserAccount(UUID.Zero, userID);
                    UUID folderID =
                        friendClient.Scene.InventoryService.GetFolderForType(friendID, InventoryType.Unknown,
                                                                             AssetType.CallingCard).ID;
                    ccmodule.CreateCallingCard(friendClient, userID, folderID, account.Name);
                }
                // we're done
                return true;
            }

            return false;
        }
开发者ID:TechplexEngineer,项目名称:Aurora-Sim,代码行数:37,代码来源:FriendsModule.cs

示例3: SendFriendsOnlineIfNeeded

        public void SendFriendsOnlineIfNeeded(IClientAPI client)
        {
            UUID agentID = client.AgentId;
            if (m_NeedsListOfFriends.Contains(agentID))
            {
                if (!m_Friends.ContainsKey(agentID))
                {
                    m_log.DebugFormat("[FRIENDS MODULE]: agent {0} not found in local cache", agentID);
                    return;
                }

                //
                // Send the friends online
                //
                List<UUID> online = GetOnlineFriends(agentID);
                if (online.Count > 0)
                {
                    m_log.DebugFormat("[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count);
                    client.SendAgentOnline(online.ToArray());
                }

                //
                // Send outstanding friendship offers
                //
                if (m_Friends.ContainsKey(agentID))
                {
                    List<string> outstanding = new List<string>();

                    foreach (FriendInfo fi in m_Friends[agentID].Friends)
                        if (fi.TheirFlags == -1)
                            outstanding.Add(fi.Friend);

                    GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, "", agentID, (byte)InstantMessageDialog.FriendshipOffered, "Will you be my friend?", true, Vector3.Zero);
                    foreach (string fid in outstanding)
                    {
                        try
                        {
                            im.fromAgentID = new Guid(fid);
                        }
                        catch
                        {
                            continue;
                        }

                        UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, new UUID(im.fromAgentID));
                        im.fromAgentName = account.FirstName + " " + account.LastName;

                        PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid });
                        PresenceInfo presence = PresenceInfo.GetOnlinePresence(presences);
                        if (presence != null)
                            im.offline = 0;

                        im.imSessionID = im.fromAgentID;

                        // Finally
                        LocalFriendshipOffered(agentID, im);
                    }
                }

                lock (m_NeedsListOfFriends)
                    m_NeedsListOfFriends.Remove(agentID);
            }
        }
开发者ID:gumho,项目名称:diva-distribution,代码行数:63,代码来源:FriendsModule.cs

示例4: OnApproveFriendRequest

        private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
        {
            m_log.DebugFormat("[FRIEND]: Got approve friendship from {0} {1}, agentID {2}, tid {3}",
                              client.Name, client.AgentId, agentID, friendID);

            // store the new friend persistently for both avatars
            m_initialScene.StoreAddFriendship(friendID, agentID, (uint) FriendRights.CanSeeOnline);

            // The cache entries aren't valid anymore either, as we just added a friend to both sides.
            lock (m_friendLists)
            {
                m_friendLists.Invalidate(agentID.ToString());
                m_friendLists.Invalidate(friendID.ToString());
            }

            // if it's a local friend, we don't have to do the lookup
            ScenePresence friendPresence = GetAnyPresenceFromAgentID(friendID);

            if (friendPresence != null)
            {
                m_log.Debug("[FRIEND]: Local agent detected.");

                // create calling card
                CreateCallingCard(client, friendID, callingCardFolders[0], friendPresence.Name);

                // local message means OnGridInstantMessage won't be triggered, so do the work here.
                friendPresence.ControllingClient.SendInstantMessage(
                        new GridInstantMessage(client.Scene, agentID,
                        client.Name, friendID,
                        (byte)InstantMessageDialog.FriendshipAccepted,
                        agentID.ToString(), false, Vector3.Zero));
                ApproveFriendship(agentID, friendID, client.Name);
            }
            else
            {
                m_log.Debug("[FRIEND]: Remote agent detected.");

                // fetch the friend's name for the calling card.
                CachedUserInfo info = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(friendID);

                // create calling card
                CreateCallingCard(client, friendID, callingCardFolders[0],
                                  info.UserProfile.FirstName + " " + info.UserProfile.SurName);

                // Compose (remote) response to friend.
                GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID,
                                                                (byte)InstantMessageDialog.FriendshipAccepted,
                                                                agentID.ToString(), false, Vector3.Zero);
                if (m_TransferModule != null)
                {
                    m_TransferModule.SendInstantMessage(msg,
                        delegate(bool success) {
                            m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
                        }
                    );
                }
            }

            // tell client that new friend is online
            client.SendAgentOnline(new UUID[] { friendID });
        }
开发者ID:Ideia-Boa,项目名称:Diva-s-OpenSim-Tests,代码行数:61,代码来源:FriendsModule.cs

示例5: SendPresenceState

        /// <summary>
        /// Send presence information about a client to other clients in both this region and others.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="friendList"></param>
        /// <param name="iAmOnline"></param>
        private void SendPresenceState(IClientAPI client, List<FriendListItem> friendList, bool iAmOnline)
        {
            //m_log.DebugFormat("[FRIEND]: {0} logged {1}; sending presence updates", client.Name, iAmOnline ? "in" : "out");

            if (friendList == null || friendList.Count == 0)
            {
                //m_log.DebugFormat("[FRIEND]: {0} doesn't have friends.", client.Name);
                return; // nothing we can do if she doesn't have friends...
            }

            // collect sets of friendIDs; to send to (online and offline), and to receive from
            // TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets.
            // I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago...
            List<UUID> friendIDsToSendTo = new List<UUID>();
            List<UUID> candidateFriendIDsToReceive = new List<UUID>();
            
            foreach (FriendListItem item in friendList)
            {
                if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0)
                {
                    // friend is allowed to see my presence => add
                    if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0) 
                        friendIDsToSendTo.Add(item.Friend);

                    if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) 
                        candidateFriendIDsToReceive.Add(item.Friend);
                }
            }

            // we now have a list of "interesting" friends (which we have to find out on-/offline state for),
            // friends we want to send our online state to (if *they* are online, too), and
            // friends we want to receive online state for (currently unknown whether online or not)

            // as this processing might take some time and friends might TP away, we try up to three times to
            // reach them. Most of the time, we *will* reach them, and this loop won't loop
            int retry = 0;
            do
            {
                // build a list of friends to look up region-information and on-/offline-state for
                List<UUID> friendIDsToLookup = new List<UUID>(friendIDsToSendTo);
                foreach (UUID uuid in candidateFriendIDsToReceive)
                {
                    if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid);
                }

                m_log.DebugFormat(
                    "[FRIEND]: {0} to lookup, {1} to send to, {2} candidates to receive from for agent {3}",
                    friendIDsToLookup.Count, friendIDsToSendTo.Count, candidateFriendIDsToReceive.Count, client.Name);

                // we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't
                // necessarily contain the correct online state...
                Dictionary<UUID, FriendRegionInfo> friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup);
                m_log.DebugFormat(
                    "[FRIEND]: Found {0} regionInfos for {1} friends of {2}",
                    friendRegions.Count, friendIDsToLookup.Count, client.Name);

                // argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops.
                UUID[] agentArr = new UUID[] { client.AgentId };

                // first, send to friend presence state to me, if I'm online...
                if (iAmOnline)
                {
                    List<UUID> friendIDsToReceive = new List<UUID>();
                    
                    for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i)
                    {
                        UUID uuid = candidateFriendIDsToReceive[i];
                        FriendRegionInfo info;
                        if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline)
                        {
                            friendIDsToReceive.Add(uuid);
                        }
                    }
                    
                    m_log.DebugFormat(
                        "[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name);
                    
                    if (friendIDsToReceive.Count > 0) 
                        client.SendAgentOnline(friendIDsToReceive.ToArray());

                    // clear them for a possible second iteration; we don't have to repeat this
                    candidateFriendIDsToReceive.Clear();
                }

                // now, send my presence state to my friends
                for (int i = friendIDsToSendTo.Count - 1; i >= 0; --i)
                {
                    UUID uuid = friendIDsToSendTo[i];
                    FriendRegionInfo info;
                    if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline)
                    {
                        // any client is good enough, root or child...
                        ScenePresence agent = GetAnyPresenceFromAgentID(uuid);
                        if (agent != null)
//.........这里部分代码省略.........
开发者ID:Ideia-Boa,项目名称:Diva-s-OpenSim-Tests,代码行数:101,代码来源:FriendsModule.cs

示例6: AddFriendship

        public void AddFriendship(IClientAPI client, UUID friendID)
        {
            StoreFriendships(client.AgentId, friendID);

            ICallingCardModule ccm = client.Scene.RequestModuleInterface<ICallingCardModule>();
            if (ccm != null)
            {
                ccm.CreateCallingCard(client.AgentId, friendID, UUID.Zero);
            }

            // Update the local cache. 
            RecacheFriends(client);

            //
            // Notify the friend
            //

            // Try Local
            if (LocalFriendshipApproved(client.AgentId, client.Name, friendID))
            {
                client.SendAgentOnline(new UUID[] { friendID });
                return;
            }

            // The friend is not here
            PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
            if (friendSessions != null && friendSessions.Length > 0)
            {
                PresenceInfo friendSession = friendSessions[0];
                if (friendSession != null)
                {
                    GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
                    m_FriendsSimConnector.FriendshipApproved(region, client.AgentId, client.Name, friendID);
                    client.SendAgentOnline(new UUID[] { friendID });
                }
            }
        }
开发者ID:justasabc,项目名称:opensim75grid,代码行数:37,代码来源:FriendsModule.cs

示例7: SendFriendsOnlineIfNeeded

        public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client)
        {
            UUID agentID = client.AgentId;

            // Check if the online friends list is needed
            lock (m_NeedsListOfOnlineFriends)
            {
                if (!m_NeedsListOfOnlineFriends.Remove(agentID))
                    return false;
            }

            // Send the friends online
            List<UUID> online = GetOnlineFriends(agentID);

            if (online.Count > 0)
                client.SendAgentOnline(online.ToArray());

            // Send outstanding friendship offers
            List<string> outstanding = new List<string>();
            FriendInfo[] friends = GetFriendsFromCache(agentID);
            foreach (FriendInfo fi in friends)
            {
                if (fi.TheirFlags == -1)
                    outstanding.Add(fi.Friend);
            }

            GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, String.Empty, agentID, (byte)InstantMessageDialog.FriendshipOffered,
                "Will you be my friend?", true, Vector3.Zero);

            foreach (string fid in outstanding)
            {
                UUID fromAgentID;
                string firstname = "Unknown", lastname = "User";
                if (!GetAgentInfo(client.Scene.RegionInfo.ScopeID, fid, out fromAgentID, out firstname, out lastname))
                {
                    m_log.DebugFormat("[FRIENDS MODULE]: skipping malformed friend {0}", fid);
                    continue;
                }

                im.offline = 0;
                im.fromAgentID = fromAgentID.Guid;
                im.fromAgentName = firstname + " " + lastname;
                im.imSessionID = im.fromAgentID;
                im.message = FriendshipMessage(fid);

                LocalFriendshipOffered(agentID, im);
            }

            return true;
        }
开发者ID:justasabc,项目名称:opensim75grid,代码行数:50,代码来源:FriendsModule.cs

示例8: OnApproveFriendRequest

        private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
        {
            m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);
            
            FriendsService.StoreFriend(agentID, friendID.ToString(), 1);
            FriendsService.StoreFriend(friendID, agentID.ToString(), 1);

            // Update the local cache
            UpdateFriendsCache(agentID);

            //
            // Notify the friend
            //

            client.SendAgentOnline(new UUID[] { friendID });

            //
            // Send calling card to the local user
            //

            ICallingCardModule ccmodule = client.Scene.RequestModuleInterface<ICallingCardModule>();
            if (ccmodule != null)
            {
                UUID folderID = ((Scene)client.Scene).InventoryService.GetFolderForType(agentID, AssetType.CallingCard).ID;
                ccmodule.CreateCallingCard(client, friendID, folderID, client.Name);
            }
                
            // Try Local
            if (LocalFriendshipApproved(agentID, client.Name, friendID))
                return;

            // The friend is not here
            PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
            if (friendSessions != null && friendSessions.Length > 0)
            {
                PresenceInfo friendSession = friendSessions[0];
                if (friendSession != null)
                {
                    GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
                    m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID);
                }
            }
        }
开发者ID:shangcheng,项目名称:Aurora,代码行数:43,代码来源:FriendsModule.cs

示例9: SendFriendsOnlineIfNeeded

        public void SendFriendsOnlineIfNeeded(IClientAPI client)
        {
            UUID agentID = client.AgentId;

            // Check if the online friends list is needed
            lock (m_NeedsListOfFriends)
            {
                if (!m_NeedsListOfFriends.Remove(agentID))
                    return;
            }

            // Send the friends online
            List<UUID> online = GetOnlineFriends(agentID);
            if (online.Count > 0)
            {
                m_log.DebugFormat("[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count);
                client.SendAgentOnline(online.ToArray());
            }

            // Send outstanding friendship offers
            List<string> outstanding = new List<string>();
            FriendInfo[] friends = GetFriends(agentID);
            foreach (FriendInfo fi in friends)
            {
                if (fi.TheirFlags == -1)
                    outstanding.Add(fi.Friend);
            }

            GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, String.Empty, agentID, (byte)InstantMessageDialog.FriendshipOffered,
                "Will you be my friend?", true, Vector3.Zero);

            foreach (string fid in outstanding)
            {
                UUID fromAgentID;
                if (!UUID.TryParse(fid, out fromAgentID))
                    continue;

                UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, fromAgentID);

                PresenceInfo presence = null;
                PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid });
                if (presences != null && presences.Length > 0)
                    presence = presences[0];
                if (presence != null)
                    im.offline = 0;

                im.fromAgentID = fromAgentID.Guid;
                im.fromAgentName = account.FirstName + " " + account.LastName;
                im.offline = (byte)((presence == null) ? 1 : 0);
                im.imSessionID = im.fromAgentID;

                // Finally
                LocalFriendshipOffered(agentID, im);
            }
        }
开发者ID:shangcheng,项目名称:Aurora,代码行数:55,代码来源:FriendsModule.cs

示例10: SendOnlineFriendsToClient

 private void SendOnlineFriendsToClient(UUID[] candidateFriendIDsToReceive, IClientAPI client)
 {
     System.Threading.Thread.Sleep(3000); //TODO: FIXME KLUDGE!
     client.SendAgentOnline(candidateFriendIDsToReceive);
 }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:5,代码来源:FriendsModule.cs


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