Exemplo n.º 1
0
 /// <summary>
 /// 仅从ForgetiveServer中调用,用于释放资源
 /// </summary>
 public void Close()
 {
     if (OtherData != null)
     {
         OtherData.Clear();
         OtherData = null;
     }
     if (ReadedData != null)
     {
         ReadedData.Clear();
         ReadedData = null;
     }
     if (PlayerContext != null)
     {
         if (PlayerContext.MapContext != null)
         {
             try
             {
                 PlayerContext.MapContext.QuitMap(PlayerContext);
             }
             catch { }
             PlayerContext.Dispose();
         }
     }
     genKey.Dispose();
     try
     {
         ClientSocket.Shutdown(SocketShutdown.Both);
         ClientSocket.Close();
     }
     catch { }
     try
     {
         if (Map != null)
         {
             for (int i = 0; i < Map.players.Count; i++)
             {
                 if (Map.players[i].SocketState == this)
                 {
                     Map.players.RemoveAt(i);
                     i--;
                     continue;
                 }
             }
         }
     }
     catch { }
     if (PlayerContext != null)
     {
         PlayerContext.Dispose();
     }
 }