/// <summary> /// Takes an <see cref="IAkkaPdu"/> representation of an Akka PDU and returns its encoded form /// as a <see cref="ByteString"/>. /// </summary> /// <param name="pdu"></param> /// <returns></returns> public virtual ByteString EncodePdu(IAkkaPdu pdu) { ByteString finalBytes = null; pdu.Match() .With <Associate>(a => finalBytes = ConstructAssociate(a.Info)) .With <Payload>(p => finalBytes = ConstructPayload(p.Bytes)) .With <Disassociate>(d => finalBytes = ConstructDisassociate(d.Reason)) .With <Heartbeat>(h => finalBytes = ConstructHeartbeat()); return(finalBytes); }
/// <summary> /// Takes an <see cref="IAkkaPdu"/> representation of an Akka PDU and returns its encoded form /// as a <see cref="ByteString"/>. /// </summary> /// <param name="pdu">TBD</param> /// <returns>TBD</returns> public virtual ByteString EncodePdu(IAkkaPdu pdu) { switch (pdu) { case Payload p: return ConstructPayload(p.Bytes); case Heartbeat h: return ConstructHeartbeat(); case Associate a: return ConstructAssociate(a.Info); case Disassociate d: return ConstructDisassociate(d.Reason); default: return null; // unsupported message type } }
/// <summary> /// Takes an <see cref="IAkkaPdu"/> representation of an Akka PDU and returns its encoded form /// as a <see cref="ByteString"/>. /// </summary> /// <param name="pdu"></param> /// <returns></returns> public virtual ByteString EncodePdu(IAkkaPdu pdu) { ByteString finalBytes = null; pdu.Match() .With<Associate>(a => finalBytes = ConstructAssociate(a.Info)) .With<Payload>(p => finalBytes = ConstructPayload(p.Bytes)) .With<Disassociate>(d => finalBytes = ConstructDisassociate(d.Reason)) .With<Heartbeat>(h => finalBytes = ConstructHeartbeat()); return finalBytes; }