Advertisement
krock186

ArmorConnect

Jul 6th, 2013
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1.     //Codes for EE to connect with ArmorGrames, the function blocks the current thread in which it was started in, maximal 6 seconds
  2.  
  3.     Client cli; //client set after ArmorConnect() ran
  4.     void ArmorConnect(string userID, string gameAuthToken) {
  5.             int done = 1;
  6.             Client cli_ = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", "guest", "guest");
  7.             Connection con_ = cli_.Multiplayer.CreateJoinRoom(null, "Auth" + version, false, null, null);
  8.             con_.OnMessage += delegate(object sender, PlayerIOClient.Message m) {
  9.                 if (m.Type == "auth") {
  10.                     if (m.Count != 0) {
  11.                         cli = PlayerIO.Connect(gameId, "secure", m.GetString(0), m.GetString(1), "armorgames");
  12.                         done -= 100;
  13.                     } else {
  14.                         cli = null;
  15.                     }
  16.  
  17.                 }
  18.             };
  19.             con_.Send("auth", userID, gameAuthToken);
  20.            
  21.             while (done > 0 && done < 24) {
  22.                 Thread.Sleep(250);
  23.                 done++;
  24.             }
  25.             if (con_ != null) {
  26.                 if (con_.Connected) {
  27.                     con_.Disconnect();
  28.                 }
  29.             }
  30.             Thread.Sleep(500);
  31.             con_ = null;
  32.             if (done > 5) {
  33.                 throw new Exception("Cant Connect");
  34.             }
  35.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement