protected bool BuildBaseUrl() { IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>(); // In case we lost the connection clear the url so it can be looked up later again if (!scm.IsHomeServerConnected) { _baseUrl = null; return(false); } if (!string.IsNullOrWhiteSpace(_baseUrl)) { return(true); } // We need to know the base url of the server's remote access service, so we can use the IP and port number. try { IRemoteResourceInformationService rris = ServiceRegistration.Get <IRemoteResourceInformationService>(); string resourceUrl; IPAddress localIpAddress; if (!rris.GetFileHttpUrl(scm.HomeServerSystemId, ResourcePath.BuildBaseProviderPath(Guid.Empty, string.Empty), out resourceUrl, out localIpAddress)) { return(false); } Uri uri = new Uri(resourceUrl); _baseUrl = uri.Authority; return(true); } catch { return(false); } }
public void PrepareStreamAccess() { if (!_isFile || _underlayingStream != null) { return; } IRemoteResourceInformationService rris = ServiceRegistration.Get <IRemoteResourceInformationService>(); string resourceURL; IPAddress localIpAddress; if (!rris.GetFileHttpUrl(_nativeSystemId, _nativeResourcePath, out resourceURL, out localIpAddress)) { return; } lock (_syncObj) _underlayingStream = new CachedMultiSegmentHttpStream(resourceURL, localIpAddress, Size); }