public void Connect(AddressCandidates addresses) { lock (base.ThisLock) { if (this.connecting) { throw new FaultException(SRClient.InvalidCallFaultException); } this.connecting = true; } try { this.localEndpoints = addresses.GetEndpoints(AddressType.Local); IPEndPoint endpoint = addresses.GetEndpoint(AddressType.External); this.ServerStartConnectingLocal(this.localEndpoints); this.ServerStartConnectingExternal(this.localDerivedEndpoint, endpoint); IOThreadScheduler.ScheduleCallbackNoFlow(new Action <object>(this.SendResponse), null); } catch (Exception exception1) { Exception exception = exception1; base.Failure(exception); throw new FaultException(exception.ToString()); } }
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; } } }
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 DirectConnectMessage(string id, AddressCandidates addresses) { this.id = id; this.addresses = addresses; }
public ConnectRetryMessage(string id, AddressCandidates addresses) { this.id = id; this.addresses = addresses; }