/// <summary> /// Connect to the server. If already connected an exception is thrown. /// </summary> /// <param name="srv">Server URL</param> /// <param name="authToken">Authorization token.</param> public async Task Connect(string srv, string authToken) { if (log.IsDebugEnabled) { log.Debug("Connecting to " + srv); } if (!IsClosed && NOT_CONNECTED == Interlocked.CompareExchange(ref _isConnected, CONNECTED, NOT_CONNECTED)) { URL = srv; _ctrl = new SControlLink(); await _ctrl.ConnectAsync(srv, authToken); OnConnect(new OnConnectEventArgs(URL)); if (log.IsDebugEnabled) { log.Debug("Connected to " + srv); } } else { if (log.IsWarnEnabled) { log.Warn("Unable to connect to " + srv); } } }
/// <summary> /// Connect to the server. If already connected an exception is thrown. /// </summary> /// <param name="srv">Server URL</param> /// <param name="authToken">Authorization token.</param> public async Task <bool> Connect(string srv, string authToken) { System.Diagnostics.Debug.WriteLine($"Connecting to {srv}"); bool connected = false; if (!IsClosed && NOT_CONNECTED == Interlocked.CompareExchange(ref _isConnected, CONNECTED, NOT_CONNECTED)) { URL = srv; _ctrl = new SControlLink(); await _ctrl.ConnectAsync(srv, authToken); OnConnect(new OnConnectEventArgs(URL)); System.Diagnostics.Debug.WriteLine($"Connected to {srv}"); connected = true; } else { System.Diagnostics.Trace.WriteLine($"Unable to connect to {srv}"); } return(connected); }
public Task ConnectAsync(string url, string authToken) { this.url = url; return(ctrlLink.ConnectAsync(url, authToken)); }