Brunet.Security.PeerSec.PeerSecAssociation.HandleIncoming C# (CSharp) Метод

HandleIncoming() защищенный Метод

All incoming data filters through here.
protected HandleIncoming ( MemBlock data, MemBlock &app_data ) : bool
data MemBlock
app_data MemBlock
Результат bool
    override protected bool HandleIncoming(MemBlock data, out MemBlock app_data)
    {
      if(!_active) {
        if(_closed == 0) {
          UpdateSH(null, null);
        }
        app_data = null;
        return false;
      }

      SecurityDataMessage sdm = new SecurityDataMessage(data);
      if(sdm.SPI != _spi) {
        throw new Exception("Invalid SPI!");
      }

      try {
        // try to decrypt the data
        lock(_sync) {
          _current_sh.DecryptAndVerify(sdm);
        }
      } catch {
        // Maybe this is just a late arriving packet, if it is, we'll just ignore it
        if(sdm.Epoch == _last_epoch) {
          app_data = null;
          return false;
        // bad packet, let's throw it away!
        } else {
          throw;
        }
      }

      app_data = sdm.Data;
      return true;
    }