Exemple #1
0
 public bool DoConnect(string strURL, int iPort)
 {
     unsafe
     {
         bool flag;
         SteamClient.Needed();
         NetCull.config.timeoutDelay = 60f;
         if (ClientConnect.Steam_GetSteamID() == 0)
         {
             LoadingScreen.Update("connection failed (no steam detected)");
             UnityEngine.Object.Destroy(base.gameObject);
             return(false);
         }
         byte[] numArray  = new byte[1024];
         IntPtr intPtr    = Marshal.AllocHGlobal(1024);
         uint   num       = ClientConnect.SteamClient_GetAuth(intPtr, 1024);
         byte[] numArray1 = new byte[num];
         Marshal.Copy(intPtr, numArray1, 0, (int)num);
         Marshal.FreeHGlobal(intPtr);
         uLink.BitStream bitStream = new uLink.BitStream(false);
         bitStream.WriteInt32(1069);
         bitStream.WriteByte(2);
         bitStream.WriteUInt64(ClientConnect.Steam_GetSteamID());
         bitStream.WriteString(Marshal.PtrToStringAnsi(ClientConnect.Steam_GetDisplayname()));
         bitStream.WriteBytes(numArray1);
         try
         {
             NetError netError = NetCull.Connect(strURL, iPort, string.Empty, new object[] { bitStream });
             if (netError == NetError.NoError)
             {
                 SteamClient.SteamClient_OnJoinServer(strURL, iPort);
                 return(true);
             }
             else
             {
                 LoadingScreen.Update(string.Concat("connection failed (", netError, ")"));
                 UnityEngine.Object.Destroy(base.gameObject);
                 flag = false;
             }
         }
         catch (Exception exception)
         {
             UnityEngine.Debug.LogException(exception);
             UnityEngine.Object.Destroy(base.gameObject);
             flag = false;
         }
         return(flag);
     }
 }