Exemple #1
0
 /// <summary>
 /// 持續接收封包,並判斷封包完整性
 /// </summary>
 private void ReceivePackage_Thread()
 {
     while (true)
     {
         byte[] Head_Bytes = RecvPacket.Head(Player.Socket);                 //接收封包Head ( 0~24 Bytes )
         if (StartOnline.isQuit)
         {
             break;                                                          //若Client端已關閉,則跳出此while循環   //判斷是否需要退出此線程(while循環)
         }
         byte[] Body_Bytes = RecvPacket.Body(Player.Socket, Head_Bytes);     //接收封包Body ( 18~Body.Lenght Bytes )
         RecvPacket.CheckPacket(Player, Head_Bytes, Body_Bytes);             //將封包存入回調列隊中,等待處理
     }
     Debug.Log($"#  Thread Close.\t Info [Thread Name : ReceivePackage_Thread()]");
 }