private void ClientSendConnectRequest(IPEndPoint externalEndpoint, List <IPEndPoint> localEndpoints) { AddressCandidates addressCandidate = new AddressCandidates(); addressCandidate.AddEndpoints(AddressType.External, new IPEndPoint[] { externalEndpoint }); addressCandidate.AddEndpoints(AddressType.Local, localEndpoints.ToArray()); try { DirectConnectionSession session = base.Session; int attempts = session.Attempts; int num = attempts; session.Attempts = attempts + 1; if (num != 0) { IDirectConnectionControl channel = base.Session.Channel; Guid id = base.Session.Id; channel.ConnectRetry(new ConnectRetryMessage(id.ToString(), addressCandidate)); } else { IDirectConnectionControl directConnectionControl = base.Session.Channel; Guid guid = base.Session.Id; directConnectionControl.Connect(new DirectConnectMessage(guid.ToString(), addressCandidate)); } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } } }
public Microsoft.ServiceBus.Channels.IConnection Connect() { Microsoft.ServiceBus.Channels.IConnection connection; try { IDirectConnectionControl directConnectionControl = this.channelFactory.CreateChannel(); ((IChannel)directConnectionControl).Open(); this.session.Channel = directConnectionControl; this.session.Initiate(); Microsoft.ServiceBus.Channels.IConnection connection1 = this.Wait(); this.session.Close(this.timeoutHelper.RemainingTime()); try { this.channelFactory.Close(this.timeoutHelper.RemainingTime()); } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception)) { throw; } Fx.Exception.TraceHandled(exception, "DirectSocketInitiator.DirectConnectWaiter.Connect", this.Activity); } connection = connection1; } finally { this.channelFactory.Abort(); } return(connection); }
private void SendResponse(object state) { try { AddressCandidates addressCandidate = new AddressCandidates(); IPEndPoint[] externalEndpoint = new IPEndPoint[] { this.localDerivedEndpoint.ExternalEndpoint }; addressCandidate.AddEndpoints(AddressType.External, externalEndpoint); IDirectConnectionControl channel = base.Session.Channel; Guid id = base.Session.Id; channel.ConnectResponse(new ConnectResponseMessage(id.ToString(), addressCandidate)); } catch (Exception exception) { base.Failure(exception); } }
public void StartConnecting() { try { IDirectConnectionControl directConnectionControl = this.channelFactory.CreateChannel(); ((IChannel)directConnectionControl).Open(); this.session.Channel = directConnectionControl; this.session.Initiate(); } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception)) { throw; } Fx.Exception.TraceHandled(exception, "DirectSocketInitiator.DirectConnectAsyncResult.StartConnecting", this.Activity); this.session.Abort(); this.channelFactory.Abort(); } }
private void WaitForTimeout(object state) { if (this.completeEvent.WaitOne(TimeSpan.FromSeconds(15), false) && this.socket != null) { base.Success(this.socket); return; } base.Session.StartActivity(new DirectConnectionSession.ListenActivity(base.Session)); try { IDirectConnectionControl channel = base.Session.Channel; Guid id = base.Session.Id; channel.SwitchRoles(new SwitchRolesMessage(id.ToString())); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } } }
public override void Start() { if (base.Session.Attempts == 4) { try { IDirectConnectionControl channel = base.Session.Channel; Guid id = base.Session.Id; channel.Abort(new AbortMessage(id.ToString())); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } } throw new CommunicationException(SRClient.MaximumAttemptsExceeded); } this.ClientStartListening(this.localDerivedEndpoint, this.localEndpoints); this.ClientSendConnectRequest(this.localDerivedEndpoint.ExternalEndpoint, this.localEndpoints); }