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); } }