コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: AkkaPduCodec.cs プロジェクト: yyp2003net/akka.net
 /// <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
     }
 }
コード例 #3
0
ファイル: AkkaPduCodec.cs プロジェクト: Micha-kun/akka.net
        /// <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;
        }