protected override async Task OpenAsync(OpenedMessage msg) { Uri uri = UriConverter.GetServerUri(false, ServerUri, EIO, Options.Path, Options.Query); _httpUri = uri + "&sid=" + msg.Sid; await base.OpenAsync(msg); }
protected override async Task OpenAsync(OpenedMessage msg) { //if (!_httpUri.Contains("&sid=")) //{ //} _httpUri += "&sid=" + msg.Sid; await base.OpenAsync(msg); }
protected virtual async Task OpenAsync(OpenedMessage msg) { OpenedMessage = msg; var connectMsg = new ConnectedMessage { Namespace = Namespace, Eio = EIO, Query = Options.Query }; for (int i = 1; i <= 3; i++) { try { await SendAsync(connectMsg.Write(), CancellationToken.None).ConfigureAwait(false); break; } catch (Exception e) { if (i == 3) { Trace.TraceError(e.ToString()); } else { await Task.Delay(TimeSpan.FromMilliseconds(Math.Pow(2, i) * 100)); } } } /* * try * { * await Policy * .Handle<Exception>() * .WaitAndRetryAsync(3, attempt => TimeSpan.FromMilliseconds(Math.Pow(2, attempt) * 100)) * .ExecuteAsync(async () => * { * await SendAsync(connectMsg.Write(), CancellationToken.None).ConfigureAwait(false); * }).ConfigureAwait(false); * * } * catch (Exception e) * { * Trace.TraceError(e.ToString()); * OnTransportClosed(); * } */ }
protected virtual async Task OpenAsync(OpenedMessage msg) { OpenedMessage = msg; if (Options.EIO == 3 && string.IsNullOrEmpty(Namespace)) { return; } var connectMsg = new ConnectedMessage { Namespace = Namespace, Eio = Options.EIO, Query = Options.Query, }; if (Options.EIO == 4) { if (Options.Auth != null) { connectMsg.AuthJsonStr = JsonSerializer.Serialize(new[] { Options.Auth }).Json.TrimStart('[').TrimEnd(']'); } } for (int i = 1; i <= 3; i++) { try { await SendAsync(connectMsg, CancellationToken.None).ConfigureAwait(false); break; } catch (Exception e) { if (i == 3) { OnError(e); } else { await Task.Delay(TimeSpan.FromMilliseconds(Math.Pow(2, i) * 100)); } } } }