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); }
public static void GetServerURLs(this ServerURIs serverUrls, UGUI user, string uri = null, int timeoutms = 20000) { var hash = new Map { ["userID"] = user.ID }; Map res = DoXmlRpcWithHashResponse(uri ?? user.HomeURI.ToString(), "get_server_urls", hash, timeoutms); serverUrls.Clear(); foreach (string key in res.Keys) { if (key.StartsWith("SRV_") && res[key] != null) { string serverType = key.Substring(4); serverUrls.Add(serverType, res[key].ToString()); } } }
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); }