Exemple #1
0
 public void Acknowledge()
 {
     if (state.GetType() == typeof(Established))
     {
         state = new Listening();
     }
     else
     {
         Console.WriteLine("状态不对,不继续执行");
     }
     state.Acknowledge();
 }
Exemple #2
0
 public void Close()
 {
     if (state.GetType() == typeof(Listening))
     {
         state = new Closed();
     }
     else
     {
         Console.WriteLine("状态不对,不继续执行");
     }
     state.Close();
 }
Exemple #3
0
 public void Open()
 {
     if (state == null)
     {
         state = new Established();
     }
     else
     {
         Console.WriteLine("状态不对,不继续执行");
     }
     state.Open();
 }