Beispiel #1
0
        private bool TryGetServices(UGUI targetAgentId, out InventoryServiceInterface inventoryService, out AssetServiceInterface assetService)
        {
            UserAgentServiceInterface userAgentService = null;

            inventoryService = null;
            assetService     = null;
            if (targetAgentId.HomeURI == null)
            {
                return(false);
            }
            var homeUri     = targetAgentId.HomeURI.ToString();
            var heloheaders = ServicePluginHelo.HeloRequest(homeUri);

            foreach (IUserAgentServicePlugin userAgentPlugin in UserAgentServicePlugins)
            {
                if (userAgentPlugin.IsProtocolSupported(homeUri, heloheaders))
                {
                    userAgentService = userAgentPlugin.Instantiate(homeUri);
                }
            }

            if (userAgentService == null)
            {
                return(false);
            }

            ServerURIs serverurls         = userAgentService.GetServerURLs(targetAgentId);
            string     inventoryServerURI = serverurls.InventoryServerURI;
            string     assetServerURI     = serverurls.AssetServerURI;

            heloheaders = ServicePluginHelo.HeloRequest(inventoryServerURI);
            foreach (IInventoryServicePlugin inventoryPlugin in InventoryServicePlugins)
            {
                if (inventoryPlugin.IsProtocolSupported(inventoryServerURI, heloheaders))
                {
                    inventoryService = inventoryPlugin.Instantiate(inventoryServerURI);
                    break;
                }
            }

            heloheaders = ServicePluginHelo.HeloRequest(assetServerURI);
            foreach (IAssetServicePlugin assetPlugin in AssetServicePlugins)
            {
                if (assetPlugin.IsProtocolSupported(assetServerURI, heloheaders))
                {
                    assetService = assetPlugin.Instantiate(assetServerURI);
                    break;
                }
            }

            return(inventoryService != null && assetService != null);
        }
        private bool TryGetExperienceService(UEI uei, out ExperienceServiceInterface experienceService)
        {
            experienceService = default(ExperienceServiceInterface);
            Dictionary <string, string> cachedheaders;
            ExperienceBrokerEntry       entry;

            if (uei.HomeURI == null)
            {
                return(false);
            }

            if (uei.AuthorizationToken == null)
            {
                /* if unset, try fetching the authorization token */
                UEI uei2;
                if (m_ExperienceNameService.TryGetValue(uei.ID, out uei2))
                {
                    uei = uei2;
                    if (uei.HomeURI == null)
                    {
                        return(false);
                    }
                }
            }

            string experienceServerURI = uei.HomeURI.ToString();

            if (m_ExperienceService != null && m_ExperienceHomeURI == experienceServerURI)
            {
                entry = new ExperienceBrokerEntry(m_ExperienceService, m_ClockSource.TickCount);
                m_NameCache[uei.ID] = entry;
                experienceService   = entry;
                return(true);
            }

            cachedheaders = ServicePluginHelo.HeloRequest(experienceServerURI);
            foreach (IExperienceServicePlugin plugin in m_ExperienceServicePlugins)
            {
                if (plugin.IsProtocolSupported(experienceServerURI, cachedheaders))
                {
                    ExperienceServiceInterface service = plugin.Instantiate(uei);
                    entry = new ExperienceBrokerEntry(service, m_ClockSource.TickCount);
                    m_NameCache[uei.ID] = entry;
                    experienceService   = entry;
                    return(true);
                }
            }
            return(false);
        }
Beispiel #3
0
        private bool RouteIM(GridInstantMessage im)
        {
            if (im.ToAgent.HomeURI == null)
            {
                return(false);
            }
            string homeUri     = im.ToAgent.HomeURI.ToString();
            var    heloheaders = ServicePluginHelo.HeloRequest(homeUri);
            UserAgentServiceInterface userAgentService = null;

            foreach (IUserAgentServicePlugin userAgentPlugin in m_UserAgentServicePlugins)
            {
                if (userAgentPlugin.IsProtocolSupported(homeUri, heloheaders))
                {
                    userAgentService = userAgentPlugin.Instantiate(homeUri);
                }
            }

            if (userAgentService == null)
            {
                return(false);
            }

            IMServiceInterface imService;

            try
            {
                imService = userAgentService.GetIMService(im.ToAgent.ID);
            }
            catch (Exception e)
            {
                m_Log.Debug($"Failed to deliver IM to {homeUri}: User lookup failed", e);
                return(false);
            }

            try
            {
                imService.Send(im);
            }
            catch (Exception e)
            {
                m_Log.Debug($"Failed to deliver IM to {homeUri}: Delivery failed", e);
                return(false);
            }

            return(true);
        }
        public static bool StartTransfer(
            UUID transactionID,
            UGUI dstAgent,
            IReadOnlyList <IUserAgentServicePlugin> userAgentServicePlugins,
            IReadOnlyList <IInventoryServicePlugin> inventoryServicePlugins,
            IReadOnlyList <IAssetServicePlugin> assetServicePlugins,
            UGUIWithName srcAgent,
            UserAgentServiceInterface srcUserAgentService,
            InventoryServiceInterface srcInventoryService,
            AssetServiceInterface srcAssetService,
            AssetType givenAssetType,
            UUID givenInventoryID,
            IMServiceInterface imService,
            Action <UUID> inventoryCreate = null)
        {
            InventoryServiceInterface dstInventoryService = null;
            AssetServiceInterface     dstAssetService     = null;
            UserAgentServiceInterface dstUserAgentService = null;

            if (dstAgent.HomeURI == null)
            {
                m_Log.ErrorFormat("No route to agent id {0}", dstAgent.ID);
                return(false);
            }

            var homeUri     = dstAgent.HomeURI.ToString();
            var heloheaders = ServicePluginHelo.HeloRequest(homeUri);

            foreach (IUserAgentServicePlugin userAgentPlugin in userAgentServicePlugins)
            {
                if (userAgentPlugin.IsProtocolSupported(homeUri, heloheaders))
                {
                    dstUserAgentService = userAgentPlugin.Instantiate(homeUri);
                }
            }

            if (dstUserAgentService == null)
            {
                m_Log.ErrorFormat("No user agent service found to agent id {0}", dstAgent.ID);
                return(false);
            }

            ServerURIs uris = dstUserAgentService.GetServerURLs(dstAgent);

            heloheaders = ServicePluginHelo.HeloRequest(uris.AssetServerURI);
            foreach (IAssetServicePlugin assetPlugin in assetServicePlugins)
            {
                if (assetPlugin.IsProtocolSupported(homeUri, heloheaders))
                {
                    dstAssetService = assetPlugin.Instantiate(homeUri);
                }
            }
            if (dstAssetService == null)
            {
                m_Log.ErrorFormat("No asset service found to agent id {0}", dstAgent.ID);
                return(false);
            }

            heloheaders = ServicePluginHelo.HeloRequest(uris.InventoryServerURI);
            foreach (IInventoryServicePlugin inventoryPlugin in inventoryServicePlugins)
            {
                if (inventoryPlugin.IsProtocolSupported(homeUri, heloheaders))
                {
                    dstInventoryService = inventoryPlugin.Instantiate(homeUri);
                }
            }

            if (dstInventoryService == null)
            {
                m_Log.ErrorFormat("No inventory service found to agent id {0}", dstAgent.ID);
                return(false);
            }

            StartTransfer(
                transactionID,
                dstAgent,
                dstUserAgentService,
                dstInventoryService,
                dstAssetService,
                srcAgent,
                srcUserAgentService,
                srcInventoryService,
                srcAssetService,
                givenAssetType,
                givenInventoryID,
                imService,
                inventoryCreate);
            return(true);
        }
Beispiel #5
0
        private void HandleStatusMsg(KeyValuePair <UGUI, bool> statusMsg)
        {
            bool isOnline = statusMsg.Value;
            UGUI user     = statusMsg.Key;

            var signalingTo = new Dictionary <string, List <FriendInfo> >();

            if (isOnline)
            {
                foreach (FriendInfo fi in m_FriendsService[user])
                {
                    string            homeURI = fi.User.HomeURI?.ToString() ?? m_GatekeeperURI;
                    List <FriendInfo> friendsPerHomeURI;
                    if ((fi.FriendGivenFlags & FriendRightFlags.SeeOnline) != 0)
                    {
                        if (!signalingTo.TryGetValue(homeURI, out friendsPerHomeURI))
                        {
                            friendsPerHomeURI = new List <FriendInfo>();
                            signalingTo.Add(homeURI, friendsPerHomeURI);
                        }
                        friendsPerHomeURI.Add(fi);
                    }
                }
            }
            else if (!m_UserSessionService.ContainsKey(user))
            {
                foreach (FriendInfo fi in m_FriendsService[user])
                {
                    string            homeURI = fi.User.HomeURI?.ToString() ?? m_GatekeeperURI;
                    List <FriendInfo> friendsPerHomeURI;
                    if ((fi.FriendGivenFlags & FriendRightFlags.SeeOnline) != 0)
                    {
                        if (!signalingTo.TryGetValue(homeURI, out friendsPerHomeURI))
                        {
                            friendsPerHomeURI = new List <FriendInfo>();
                            signalingTo.Add(homeURI, friendsPerHomeURI);
                        }
                        friendsPerHomeURI.Add(fi);
                    }
                }
            }

            if (signalingTo.Count == 0)
            {
                return;
            }

            foreach (KeyValuePair <string, List <FriendInfo> > kvp in signalingTo)
            {
                Dictionary <string, string> heloheaders;
                try
                {
                    heloheaders = ServicePluginHelo.HeloRequest(kvp.Key);
                }
                catch (Exception e)
                {
                    m_Log.Debug("Failed to retrieve user agent HELO", e);
                    continue;
                }

                if (kvp.Key == m_GatekeeperURI)
                {
                    /* local stuff */
                    if (m_FriendsSimStatusNotifierService != null)
                    {
                        try
                        {
                            m_FriendsSimStatusNotifierService.NotifyStatus(user, new List <UGUI>(from x in kvp.Value select x.Friend), isOnline);
                        }
                        catch (Exception e)
                        {
                            m_Log.Debug($"Failed to send status to {kvp.Key}", e);
                        }
                    }
                }
                else
                {
                    UserAgentServiceInterface userAgentService = null;
                    foreach (IUserAgentServicePlugin userAgentPlugin in m_UserAgentServicePlugins)
                    {
                        if (userAgentPlugin.IsProtocolSupported(kvp.Key))
                        {
                            userAgentService = userAgentPlugin.Instantiate(kvp.Key);
                            break;
                        }
                    }

                    if (userAgentService == null)
                    {
                        continue;
                    }

                    List <KeyValuePair <UGUI, string> > notifiedFriends = new List <KeyValuePair <UGUI, string> >();
                    foreach (FriendInfo fi in kvp.Value)
                    {
                        notifiedFriends.Add(new KeyValuePair <UGUI, string>(fi.Friend, fi.Secret));
                    }

                    try
                    {
                        userAgentService.NotifyStatus(notifiedFriends, user, isOnline);
                    }
                    catch (Exception e)
                    {
                        m_Log.Debug($"Failed to send status to {kvp.Key}", e);
                    }
                }
            }
        }
Beispiel #6
0
        private bool TryGetGroupsService(UGI ugi, out GroupsBrokerEntry groupsService)
        {
            groupsService = default(GroupsBrokerEntry);
            Dictionary <string, string> cachedheaders;
            GroupsBrokerEntry           entry;

            if (ugi.HomeURI == null)
            {
                return(false);
            }

            if (ugi.AuthorizationToken == null)
            {
                /* if unset, try fetching the authorization token */
                UGI ugi2;
                if (m_GroupsNameService.TryGetValue(ugi.ID, out ugi2))
                {
                    ugi = ugi2;
                    if (ugi.HomeURI == null)
                    {
                        return(false);
                    }
                }
            }

            string groupsServerURI = ugi.HomeURI.ToString();

            if (m_GroupsService != null && m_GroupsHomeURI == groupsServerURI)
            {
                entry = new GroupsBrokerEntry(m_GroupsService, m_GroupIMRouter, m_ClockSource.TickCount);
                m_NameCache[ugi.ID] = entry;
                groupsService       = entry;
                return(true);
            }

            cachedheaders = ServicePluginHelo.HeloRequest(groupsServerURI);

            foreach (IGroupsServicePlugin plugin in m_GroupsServicePlugins)
            {
                if (plugin.IsProtocolSupported(groupsServerURI, cachedheaders))
                {
                    GroupsServiceInterface service = plugin.Instantiate(ugi);

                    IGroupsChatServiceInterface chatService = service as IGroupsChatServiceInterface;
                    if (chatService == null)
                    {
                        /* do not search for it if the groups connector has it integrated */
                        foreach (IGroupsChatServicePlugin chatplugin in m_GroupsChatServicePlugins)
                        {
                            if (chatplugin.IsProtocolSupported(groupsServerURI, cachedheaders))
                            {
                                chatService = chatplugin.Instantiate(ugi);
                                break;
                            }
                        }
                    }

                    entry = new GroupsBrokerEntry(service, chatService, m_ClockSource.TickCount);
                    m_NameCache[ugi.ID] = entry;
                    groupsService       = entry;
                    return(true);
                }
            }
            return(false);
        }