internal void DatagramReceived( BufRefLen recvbuf, IPEndPoint remoteep ) { if ( Terminated ) throw new EndOfStreamEncounteredException(); #if LOG_ALL_TRANSPORT Logging.LogTransport( string.Format( "SSUSession +{0}+: Received {1} bytes [0x{1:X}].", TransportInstance, recvbuf.Length ) ); #endif var cs = CurrentState; if ( cs != null ) CurrentState = cs.DatagramReceived( recvbuf, remoteep ); }
internal bool Run() { while (ReceiveQueue.Count > 0) { BufRefLen data; lock ( ReceiveQueue ) { data = ReceiveQueue.First.Value; ReceiveQueue.RemoveFirst(); } DatagramReceived(data, null); } var cs = CurrentState; if (cs == null) { IsTerminated = true; return(false); } // TODO: Handle exceptions and make sure ConnectionShutDown gets called. CurrentState = cs.Run(); if (CurrentState != null && cs != CurrentState) { CurrentState = CurrentState.Run(); } if (CurrentState == null) { DebugUtils.Log(string.Format("SSUSession {0}: Shuting down. No state.", DebugId)); Host.NoCpu(this); if (ConnectionShutDown != null) { ConnectionShutDown(this); } IsTerminated = true; return(false); } return(true); }
SSUState HandleRelayResponse(RelayResponse response) { var cep = response.CharlieEndpoint; Logging.LogTransport($"SSU RelayRequestState: {Session.DebugId} RelayResponse {response}"); var noncematch = Nonce == response.Nonce.Peek32(0); Logging.LogTransport($"SSU RelayRequestState: {Session.DebugId} Nonce match: {noncematch}"); if (!noncematch) { return(this); } Session.RemoteEP = response.CharlieEndpoint; Session.Host.RelayResponseReceived -= Host_RelayResponseReceived; NextState = new SessionRequestState(Session); return(NextState); }