示例#1
0
        public override void MessageReceived(ReceiverStmContext context)
        {
            if (context.ValidateMessage())
            {
                if (context.MessageType == DataType.Syn && context.ValidSync())
                {
                    Console.WriteLine("ReceivingState\t Valid Sync");
                    context.UpdateSequence();
                    context.SetAckReply();
                    context.IncrementSequence();
                    context.SendReply();
                    return;
                }

                if (context.MessageType == DataType.Data && context.ValidData())
                {
                    Console.WriteLine("ReceivingState\t Valid Data");
                    if (context.ValidSequence())
                    {
                        context.SetAckReply();
                        context.IncrementSequence();
                        context.Ready = true;
                    }

                    context.SendReply();
                    return;
                }

            }
        }
示例#2
0
 public override void MessageReceived(ReceiverStmContext context)
 {
     if (context.ValidateMessage())
     {
         Console.WriteLine("MissingSyncState Valid Message: " + (char)context.MessageType);
         if (context.MessageType == DataType.Syn && context.ValidSync())
         {
             Console.WriteLine("MissingSyncState Got sync");
             context.UpdateSequence();
             context.SetAckReply();
             context.IncrementSequence();
             context.SendReply();
             context.SetState(new Receiving());
         }
     }
 }