protected override bool EqualsTo(Cell other) { if (!base.EqualsTo(other)) { return(false); } HandshakeAck o = (HandshakeAck)other; if (result_ != o.result_) { return(false); } return(true); }
protected override bool IsEquivalent(Cell other, Fingerprint fingerprint) { if (!base.IsEquivalent(other, fingerprint)) { return(false); } HandshakeAck o = (HandshakeAck)other; var touched = new Capo <bool>(fingerprint, tag.Offset); if (touched[0]) { if (result_ != o.result_) { return(false); } } return(true); }
public override bool Process(Event e) { switch (e.GetTypeId()) { case (int)LinkEventType.HandshakeReq: { var req = (HandshakeReq)e; var resp = new HandshakeResp { _Transform = false }; byte[] response = null; try { ManualResetEvent waitHandle = SignalPool.Acquire(Session.InternalHandle); waitHandle.WaitOne(new TimeSpan(0, 0, 30)); SignalPool.Release(Session.InternalHandle); response = BufferTransform.Handshake(req.Data); } catch (Exception ex) { Trace.Error("{0} {1} error handshaking : {2}", Session.Link.Name, Session.InternalHandle, ex.ToString()); } if (response != null) { resp.Data = response; } Session.Send(resp); } break; case (int)LinkEventType.HandshakeResp: { var ack = new HandshakeAck { _Transform = false }; var resp = (HandshakeResp)e; try { if (BufferTransform.FinalizeHandshake(resp.Data)) { rxTransformReady = true; ack.Result = true; } } catch (Exception ex) { Trace.Error("{0} {1} error finishing handshake : {2}", Session.Link.Name, Session.InternalHandle, ex.ToString()); } Session.Send(ack); } break; case (int)LinkEventType.HandshakeAck: { var ack = (HandshakeAck)e; bool result = ack.Result; if (result) { txTransformReady = true; } Session.Link.OnLinkSessionConnectedInternal(result, (result ? Session: null)); } break; default: return false; } return true; }