Beispiel #1
0
 public static void PutInfoDestination(this IoBuffer buffer, InfoDestination msg)
 {
     buffer.PutGuidPrefix(msg.GuidPrefix);
 }
Beispiel #2
0
 public static InfoDestination GetInfoDestination(this IoBuffer buffer)
 {
     InfoDestination obj = new InfoDestination();
     buffer.GetInfoDestination(ref obj);
     return obj;
 }
Beispiel #3
0
 public static void GetInfoDestination(this IoBuffer buffer, ref InfoDestination obj)
 {
     obj.GuidPrefix = buffer.GetGuidPrefix();
 }
Beispiel #4
0
        public static void GetSubMessage(this IoBuffer buffer, ref SubMessage obj)
        {
            buffer.Align(4);
            int smhPosition = buffer.Position;

            SubMessageHeader header = buffer.GetSubMessageHeader();
            int smStart = buffer.Position;

            switch (header.SubMessageKind)
            { // @see 9.4.5.1.1
                case SubMessageKind.PAD:
                    Pad smPad = new Pad();
                    smPad.Header = header;
                    buffer.GetPad(ref smPad);
                    obj = smPad;
                    break;
                case SubMessageKind.ACKNACK:
                    AckNack smAckNack = new AckNack();
                    smAckNack.Header = header;
                    buffer.GetAckNack(ref smAckNack);
                    obj = smAckNack;
                    break;
                case SubMessageKind.HEARTBEAT:
                    Heartbeat smHeartbeat = new Heartbeat();
                    smHeartbeat.Header = header;
                    buffer.GetHeartbeat(ref smHeartbeat);
                    obj = smHeartbeat;
                    break;
                case SubMessageKind.GAP:
                    Gap smgap = new Gap();
                    smgap.Header = header;
                    buffer.GetGap(ref smgap);
                    obj = smgap;
                    break;
                case SubMessageKind.INFO_TS:
                    InfoTimestamp sminfots = new InfoTimestamp();
                    sminfots.Header = header;
                    buffer.GetInfoTimestamp(ref sminfots);
                    obj = sminfots;
                    break;
                case SubMessageKind.INFO_SRC:
                    InfoSource smInfoSource = new InfoSource();
                    smInfoSource.Header = header;
                    buffer.GetInfoSource(ref smInfoSource);
                    obj = smInfoSource;
                    break;
                case SubMessageKind.INFO_REPLY_IP4:
                    InfoReplyIp4 smInfoReplyIp4 = new InfoReplyIp4();
                    smInfoReplyIp4.Header = header;
                    buffer.GetInfoReplyIp4(ref smInfoReplyIp4);
                    obj = smInfoReplyIp4;
                    break;
                case SubMessageKind.INFO_DST:
                    InfoDestination smInfoDestination = new InfoDestination();
                    smInfoDestination.Header = header;
                    buffer.GetInfoDestination(ref smInfoDestination);
                    obj = smInfoDestination;
                    break;
                case SubMessageKind.INFO_REPLY:
                    InfoReply smInfoReply = new InfoReply();
                    smInfoReply.Header = header;
                    buffer.GetInfoReply(ref smInfoReply);
                    obj = smInfoReply;
                    break;
                case SubMessageKind.NACK_FRAG:
                    NackFrag smNackFrag = new NackFrag();
                    smNackFrag.Header = header;
                    buffer.GetNackFrag(ref smNackFrag);
                    obj = smNackFrag;
                    break;
                case SubMessageKind.HEARTBEAT_FRAG:
                    HeartbeatFrag smHeartbeatFrag = new HeartbeatFrag();
                    smHeartbeatFrag.Header = header;
                    buffer.GetHeartbeatFrag(ref smHeartbeatFrag);
                    obj = smHeartbeatFrag;
                    break;
                case SubMessageKind.DATA:
                    Data smdata = new Data();
                    smdata.Header = header;
                    buffer.GetDataSubMessage(ref smdata);
                    obj = smdata;
                    break;
                case SubMessageKind.DATA_FRAG:
                    DataFrag smdDataFrag = new DataFrag();
                    smdDataFrag.Header = header;
                    buffer.GetDataFrag(ref smdDataFrag);
                    obj = smdDataFrag;
                    break;

                default:
                    throw new NotSupportedException();
            }

            int smEnd = buffer.Position;
            int smLength = smEnd - smStart;
            if (smLength != header.SubMessageLength && header.SubMessageLength != 0)
            {
                log.WarnFormat("SubMessage length differs for {0} != {1} for {2}", smLength, header.SubMessageLength, obj);
                if (smLength < header.SubMessageLength)
                {
                    byte[] unknownBytes = new byte[header.SubMessageLength - smLength];
                    log.DebugFormat("Trying to skip {0} bytes", unknownBytes.Length);

                    buffer.Get(unknownBytes, 0, unknownBytes.Length);
                }
            }

            log.DebugFormat("SubMsg in:  {0}", obj);
        }