Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. // Decompiled with JetBrains decompiler
  2. // Type: ExitGames.Client.Photon.Chat.ChatPeer
  3. // Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
  4. // MVID: 3C42920B-2519-4F2C-A0E9-95338DCC9376
  5. // Assembly location: C:\Users\FruityFusion\Desktop\Assembly-CSharp.dll
  6.  
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10.  
  11. namespace ExitGames.Client.Photon.Chat
  12. {
  13. public class ChatPeer : PhotonPeer
  14. {
  15. public const string NameServerHost = "ns.exitgames.com";
  16. public const string NameServerHttp = "http://ns.exitgamescloud.com:80/photon/n";
  17. private static readonly Dictionary<ConnectionProtocol, int> ProtocolToNameServerPort;
  18.  
  19. public ChatPeer(IPhotonPeerListener listener, ConnectionProtocol protocol)
  20. {
  21. base.\u002Ector(listener, protocol);
  22. this.ConfigUnitySockets();
  23. }
  24.  
  25. public string NameServerAddress
  26. {
  27. get
  28. {
  29. return this.GetNameServerAddress();
  30. }
  31. }
  32.  
  33. internal virtual bool IsProtocolSecure
  34. {
  35. get
  36. {
  37. return this.get_UsedProtocol() == 5;
  38. }
  39. }
  40.  
  41. [Conditional("UNITY")]
  42. private void ConfigUnitySockets()
  43. {
  44. Type type = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp", false) ?? Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp-firstpass", false);
  45. if (type == null)
  46. return;
  47. ((Dictionary<ConnectionProtocol, Type>) this.SocketImplementationConfig)[(ConnectionProtocol) 4] = type;
  48. ((Dictionary<ConnectionProtocol, Type>) this.SocketImplementationConfig)[(ConnectionProtocol) 5] = type;
  49. }
  50.  
  51. private string GetNameServerAddress()
  52. {
  53. int num = 0;
  54. ChatPeer.ProtocolToNameServerPort.TryGetValue(this.get_TransportProtocol(), out num);
  55. switch ((int) this.get_TransportProtocol())
  56. {
  57. case 0:
  58. case 1:
  59. return string.Format("{0}:{1}", (object) "ns.exitgames.com", (object) num);
  60. case 4:
  61. return string.Format("ws://{0}:{1}", (object) "ns.exitgames.com", (object) num);
  62. case 5:
  63. return string.Format("wss://{0}:{1}", (object) "ns.exitgames.com", (object) num);
  64. default:
  65. throw new ArgumentOutOfRangeException();
  66. }
  67. }
  68.  
  69. public bool Connect()
  70. {
  71. if (this.DebugOut >= 3)
  72. this.get_Listener().DebugReturn((DebugLevel) 3, "Connecting to nameserver " + this.NameServerAddress);
  73. return this.Connect(this.NameServerAddress, "NameServer");
  74. }
  75.  
  76. public bool AuthenticateOnNameServer(string appId, string appVersion, string region, AuthenticationValues authValues)
  77. {
  78. if (this.DebugOut >= 3)
  79. this.get_Listener().DebugReturn((DebugLevel) 3, "OpAuthenticate()");
  80. Dictionary<byte, object> dictionary = new Dictionary<byte, object>();
  81. dictionary[(byte) 220] = (object) appVersion;
  82. dictionary[(byte) 224] = (object) appId;
  83. dictionary[(byte) 210] = (object) region;
  84. if (authValues != null)
  85. {
  86. if (!string.IsNullOrEmpty(authValues.UserId))
  87. dictionary[(byte) 225] = (object) authValues.UserId;
  88. if (authValues != null && authValues.AuthType != CustomAuthenticationType.None)
  89. {
  90. dictionary[(byte) 217] = (object) authValues.AuthType;
  91. if (!string.IsNullOrEmpty(authValues.Token))
  92. {
  93. dictionary[(byte) 221] = (object) authValues.Token;
  94. }
  95. else
  96. {
  97. if (!string.IsNullOrEmpty(authValues.AuthGetParameters))
  98. dictionary[(byte) 216] = (object) authValues.AuthGetParameters;
  99. if (authValues.AuthPostData != null)
  100. dictionary[(byte) 214] = authValues.AuthPostData;
  101. }
  102. }
  103. }
  104. return this.OpCustom((byte) 230, dictionary, true, (byte) 0, this.get_IsEncryptionAvailable());
  105. }
  106.  
  107. static ChatPeer()
  108. {
  109. Dictionary<ConnectionProtocol, int> dictionary = new Dictionary<ConnectionProtocol, int>();
  110. dictionary.Add((ConnectionProtocol) 0, 5058);
  111. dictionary.Add((ConnectionProtocol) 1, 4533);
  112. dictionary.Add((ConnectionProtocol) 4, 9093);
  113. dictionary.Add((ConnectionProtocol) 5, 19093);
  114. ChatPeer.ProtocolToNameServerPort = dictionary;
  115. }
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement