Beispiel #1
0
        private ByteString ConstructControlMessagePdu(CommandType code, AkkaHandshakeInfo.Builder handshakeInfo = null)
        {
            var controlMessageBuilder = AkkaControlMessage.CreateBuilder()
                                        .SetCommandType(code);

            if (handshakeInfo != null)
            {
                controlMessageBuilder = controlMessageBuilder.SetHandshakeInfo(handshakeInfo);
            }

            return
                (AkkaProtocolMessage.CreateBuilder().SetInstruction(controlMessageBuilder.Build()).Build().ToByteString());
        }
Beispiel #2
0
 public override IAkkaPdu DecodePdu(ByteString raw)
 {
     try
     {
         var pdu = AkkaProtocolMessage.ParseFrom(raw);
         if (pdu.HasPayload)
         {
             return(new Payload(pdu.Payload));
         }
         else if (pdu.HasInstruction)
         {
             return(DecodeControlPdu(pdu.Instruction));
         }
         else
         {
             throw new PduCodecException("Error decoding Akka PDU: Neither message nor control message were contained");
         }
     }
     catch (InvalidProtocolBufferException ex)
     {
         throw new PduCodecException("Decoding PDU failed", ex);
     }
 }
Beispiel #3
0
 public override ByteString ConstructPayload(ByteString payload)
 {
     return(AkkaProtocolMessage.CreateBuilder().SetPayload(payload).Build().ToByteString());
 }