コード例 #1
0
 public static void GetAckNack(this IoBuffer buffer, ref AckNack obj)
 {
     obj.ReaderId = buffer.GetEntityId();
     obj.WriterId = buffer.GetEntityId();
     obj.ReaderSNState = buffer.GetSequenceNumberSet();
     obj.Count = buffer.GetInt32();
 }
コード例 #2
0
 public static void PutAckNack(this IoBuffer buffer, AckNack obj)
 {
     buffer.PutEntityId(obj.ReaderId);
     buffer.PutEntityId(obj.WriterId);
     buffer.PutSequenceNumberSet(obj.ReaderSNState);
     buffer.PutInt32(obj.Count);
 }
コード例 #3
0
 public static AckNack GetAckNack(this IoBuffer buffer)
 {
     AckNack obj = new AckNack();
     buffer.GetAckNack(ref obj);
     return obj;
 }
コード例 #4
0
ファイル: SubMessageEncoder.cs プロジェクト: Egipto87/DOOP.ec
        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);
        }