/// <summary> /// Change the connection details used to connect to the uTorrent Web UI /// </summary> /// <param name="ServerAddress">The address of the uTorrent Web UI. This can be expressed as a hostname (e.g. utorrent.mynetwork.com) or an IP address (e.g. 10.11.12.13). This can optionally include a preceeding 'http://' and a suffix '/gui/'. If these elements are not included, they will be added.</param> /// <param name="UserName">The username used to access the uTorrent Web UI.</param> /// <param name="Password">The password used to access the uTorrent Web UI.</param> public void SetConnectionDetails(string ServerAddress, string UserName, string Password) { _torrentsAndLabelsListStored = false; _uTorrentAddress = ProcessServerAddress(ServerAddress); _uTorrentUserName = UserName; _uTorrentPassword = Password; CustomBinding uTorrentCustomBinding = new CustomBinding( new WebMessageEncodingBindingElement() { ContentTypeMapper = new JsonContentTypeMapper() }, new HttpTransportBindingElement() { ManualAddressing = true, AuthenticationScheme = System.Net.AuthenticationSchemes.Basic, Realm = "uTorrent", AllowCookies = true, KeepAliveEnabled = true, UseDefaultWebProxy = false } ); EndpointAddress uTorrentEndpointAddress = new EndpointAddress(_uTorrentAddress); ChannelFactory = new WebChannelFactory <IUTorrentWebClient>(uTorrentCustomBinding); ChannelFactory.Endpoint.Address = uTorrentEndpointAddress; ChannelFactory.Credentials.UserName.UserName = _uTorrentUserName; ChannelFactory.Credentials.UserName.Password = _uTorrentPassword; ServiceClient = ChannelFactory.CreateChannel(); this.GetToken(); }
public void Dispose() { ServiceClient = null; ChannelFactory.Close(); ChannelFactory = null; if (_autoUpdateTimerSync != null) { _autoUpdateTimerSync.Stop(); _autoUpdateTimerSync.Dispose(); } _autoUpdateTimerSync = null; if (_autoUpdateTimerAsync != null) { _autoUpdateTimerAsync.Stop(); _autoUpdateTimerAsync.Dispose(); } _autoUpdateTimerAsync = null; _token = null; }
public void Dispose() { ServiceClient = null; ChannelFactory.Close(); ChannelFactory = null; }
/// <summary> /// Change the connection details used to connect to the uTorrent Web UI /// </summary> /// <param name="ServerAddress">The address of the uTorrent Web UI. This can be expressed as a hostname (e.g. utorrent.mynetwork.com) or an IP address (e.g. 10.11.12.13). This can optionally include a preceeding 'http://' and a suffix '/gui/'. If these elements are not included, they will be added.</param> /// <param name="UserName">The username used to access the uTorrent Web UI.</param> /// <param name="Password">The password used to access the uTorrent Web UI.</param> public void SetConnectionDetails(string ServerAddress, string UserName, string Password) { _torrentsAndLabelsListStored = false; _uTorrentAddress = ProcessServerAddress(ServerAddress); _uTorrentUserName = UserName; _uTorrentPassword = Password; CustomBinding uTorrentCustomBinding = new CustomBinding( new WebMessageEncodingBindingElement() { ContentTypeMapper = new JsonContentTypeMapper() }, new HttpTransportBindingElement() { ManualAddressing = true, AuthenticationScheme = System.Net.AuthenticationSchemes.Basic, Realm = "uTorrent", AllowCookies = true } ); EndpointAddress uTorrentEndpointAddress = new EndpointAddress(_uTorrentAddress); ChannelFactory = new WebChannelFactory<IUTorrentWebClient>(uTorrentCustomBinding); ChannelFactory.Endpoint.Address = uTorrentEndpointAddress; ChannelFactory.Endpoint.Behaviors.Add(new CookieManagerEndpointBehavior()); ChannelFactory.Credentials.UserName.UserName = _uTorrentUserName; ChannelFactory.Credentials.UserName.Password = _uTorrentPassword; ServiceClient = ChannelFactory.CreateChannel(); this.getToken(); }
public void Dispose() { ServiceClient = null; ChannelFactory.Close(); ChannelFactory = null; if(_autoUpdateTimerSync != null) { _autoUpdateTimerSync.Stop(); _autoUpdateTimerSync.Dispose(); } _autoUpdateTimerSync = null; if(_autoUpdateTimerAsync != null) { _autoUpdateTimerAsync.Stop(); _autoUpdateTimerAsync.Dispose(); } _autoUpdateTimerAsync = null; _token = null; }