static void SetupServer()
 {
     for (int i = 0; i < Constants.MAX_PLAYERS; i++)
     {
         SwayTCP.Clients[i]  = new Client();
         Types.TempPlayer[i] = new Types.TempPlayerRec();
     }
     ServerHandleData.InitPackets();
     SwayTCP.InitializeNetwork();
 }
 private void OnReceiveData(IAsyncResult ar)
 {
     try
     {
         int readBytes = _stream.EndRead(ar);
         if (readBytes <= 0)
         {
             CloseSocket();
             return;
         }
         byte[] newBytes = new byte[readBytes];
         Buffer.BlockCopy(readbuffer, 0, newBytes, 0, readBytes);
         ServerHandleData.HandleData(_index, newBytes);
         _stream.BeginRead(readbuffer, 0, _socket.ReceiveBufferSize, OnReceiveData, null);
     }
     catch (Exception)
     {
         CloseSocket();
         return;
     }
 }