using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Threading; using Photon.SocketServer.Security; namespace ExitGames.Client.Photon { // Token: 0x02000012 RID: 18 public abstract class PeerBase { // Token: 0x1700003D RID: 61 // (get) Token: 0x060000FB RID: 251 RVA: 0x00008C5C File Offset: 0x00006E5C internal string ClientVersion { get { return this.ppeer.ClientVersion; } } // Token: 0x1700003E RID: 62 // (get) Token: 0x060000FC RID: 252 RVA: 0x00008C7C File Offset: 0x00006E7C internal Type SocketImplementation { get { return this.ppeer.SocketImplementation; } } // Token: 0x1700003F RID: 63 // (get) Token: 0x060000FD RID: 253 RVA: 0x00008C99 File Offset: 0x00006E99 // (set) Token: 0x060000FE RID: 254 RVA: 0x00008CA1 File Offset: 0x00006EA1 public string ServerAddress { get; internal set; } // Token: 0x17000040 RID: 64 // (get) Token: 0x060000FF RID: 255 RVA: 0x00008CAA File Offset: 0x00006EAA // (set) Token: 0x06000100 RID: 256 RVA: 0x00008CB2 File Offset: 0x00006EB2 internal string HttpUrlParameters { get; set; } // Token: 0x17000041 RID: 65 // (get) Token: 0x06000101 RID: 257 RVA: 0x00008CBC File Offset: 0x00006EBC internal bool TrafficStatsEnabled { get { return this.ppeer.TrafficStatsEnabled; } } // Token: 0x17000042 RID: 66 // (get) Token: 0x06000102 RID: 258 RVA: 0x00008CDC File Offset: 0x00006EDC internal TrafficStats TrafficStatsIncoming { get { return this.ppeer.TrafficStatsIncoming; } } // Token: 0x17000043 RID: 67 // (get) Token: 0x06000103 RID: 259 RVA: 0x00008CFC File Offset: 0x00006EFC internal TrafficStats TrafficStatsOutgoing { get { return this.ppeer.TrafficStatsOutgoing; } } // Token: 0x17000044 RID: 68 // (get) Token: 0x06000104 RID: 260 RVA: 0x00008D1C File Offset: 0x00006F1C internal TrafficStatsGameLevel TrafficStatsGameLevel { get { return this.ppeer.TrafficStatsGameLevel; } } // Token: 0x17000045 RID: 69 // (get) Token: 0x06000105 RID: 261 RVA: 0x00008D3C File Offset: 0x00006F3C internal bool crcEnabled { get { return this.ppeer.CrcEnabled; } } // Token: 0x17000046 RID: 70 // (get) Token: 0x06000106 RID: 262 RVA: 0x00008D5C File Offset: 0x00006F5C internal IPhotonPeerListener Listener { get { return this.ppeer.Listener; } } // Token: 0x17000047 RID: 71 // (get) Token: 0x06000107 RID: 263 RVA: 0x00008D7C File Offset: 0x00006F7C internal DebugLevel debugOut { get { return this.ppeer.DebugOut; } } // Token: 0x17000048 RID: 72 // (get) Token: 0x06000108 RID: 264 RVA: 0x00008D9C File Offset: 0x00006F9C internal int sentCountAllowance { get { return this.ppeer.SentCountAllowance; } } // Token: 0x17000049 RID: 73 // (get) Token: 0x06000109 RID: 265 RVA: 0x00008DBC File Offset: 0x00006FBC internal int DisconnectTimeout { get { return this.ppeer.DisconnectTimeout; } } // Token: 0x1700004A RID: 74 // (get) Token: 0x0600010A RID: 266 RVA: 0x00008DDC File Offset: 0x00006FDC internal int timePingInterval { get { return this.ppeer.TimePingInterval; } } // Token: 0x1700004B RID: 75 // (get) Token: 0x0600010B RID: 267 RVA: 0x00008DFC File Offset: 0x00006FFC internal byte ChannelCount { get { return this.ppeer.ChannelCount; } } // Token: 0x1700004C RID: 76 // (get) Token: 0x0600010C RID: 268 RVA: 0x00008E1C File Offset: 0x0000701C internal int limitOfUnreliableCommands { get { return this.ppeer.LimitOfUnreliableCommands; } } // Token: 0x1700004D RID: 77 // (get) Token: 0x0600010D RID: 269 RVA: 0x00008E3C File Offset: 0x0000703C public byte QuickResendAttempts { get { return this.ppeer.QuickResendAttempts; } } // Token: 0x1700004E RID: 78 // (get) Token: 0x0600010E RID: 270 RVA: 0x00008E5C File Offset: 0x0000705C public NetworkSimulationSet NetworkSimulationSettings { get { return this.networkSimulationSettings; } } // Token: 0x1700004F RID: 79 // (get) Token: 0x0600010F RID: 271 RVA: 0x00008E74 File Offset: 0x00007074 internal int CommandLogSize { get { return this.ppeer.CommandLogSize; } } // Token: 0x06000110 RID: 272 RVA: 0x00008E94 File Offset: 0x00007094 internal void CommandLogResize() { bool flag = this.CommandLogSize <= 0; if (flag) { this.CommandLog = null; this.InReliableLog = null; } else { bool flag2 = this.CommandLog == null || this.InReliableLog == null; if (flag2) { this.CommandLogInit(); } while (this.CommandLog.Count > 0 && this.CommandLog.Count > this.CommandLogSize) { this.CommandLog.Dequeue(); } while (this.InReliableLog.Count > 0 && this.InReliableLog.Count > this.CommandLogSize) { this.InReliableLog.Dequeue(); } } } // Token: 0x06000111 RID: 273 RVA: 0x00008F58 File Offset: 0x00007158 internal void CommandLogInit() { bool flag = this.CommandLogSize <= 0; if (flag) { this.CommandLog = null; this.InReliableLog = null; } else { bool flag2 = this.CommandLog == null || this.InReliableLog == null; if (flag2) { this.CommandLog = new Queue(this.CommandLogSize); this.InReliableLog = new Queue(this.CommandLogSize); } else { this.CommandLog.Clear(); this.InReliableLog.Clear(); } } } // Token: 0x06000112 RID: 274 RVA: 0x00008FE0 File Offset: 0x000071E0 public string CommandLogToString() { StringBuilder stringBuilder = new StringBuilder(); int num = ((this.usedProtocol != ConnectionProtocol.Udp) ? 0 : ((EnetPeer)this).reliableCommandsRepeated); stringBuilder.AppendFormat("PeerId: {0} Now: {1} Server: {2} State: {3} Total Resends: {4} Received {5}ms ago.\n", new object[] { this.PeerID, this.timeInt, this.ServerAddress, this.peerConnectionState, num, SupportClass.GetTickCount() - this.timestampOfLastReceive }); bool flag = this.CommandLog == null; string text; if (flag) { text = stringBuilder.ToString(); } else { foreach (CmdLogItem cmdLogItem in this.CommandLog) { stringBuilder.AppendLine(cmdLogItem.ToString()); } stringBuilder.AppendLine("Received Reliable Log: "); foreach (CmdLogItem cmdLogItem2 in this.InReliableLog) { stringBuilder.AppendLine(cmdLogItem2.ToString()); } text = stringBuilder.ToString(); } return text; } // Token: 0x17000050 RID: 80 // (get) Token: 0x06000113 RID: 275 RVA: 0x0000913C File Offset: 0x0000733C internal long BytesOut { get { return this.bytesOut; } } // Token: 0x17000051 RID: 81 // (get) Token: 0x06000114 RID: 276 RVA: 0x00009154 File Offset: 0x00007354 internal long BytesIn { get { return this.bytesIn; } } // Token: 0x17000052 RID: 82 // (get) Token: 0x06000115 RID: 277 internal abstract int QueuedIncomingCommandsCount { get; } // Token: 0x17000053 RID: 83 // (get) Token: 0x06000116 RID: 278 internal abstract int QueuedOutgoingCommandsCount { get; } // Token: 0x17000054 RID: 84 // (get) Token: 0x06000117 RID: 279 RVA: 0x0000916C File Offset: 0x0000736C public virtual string PeerID { get { return ((ushort)this.peerID).ToString(); } } // Token: 0x17000055 RID: 85 // (get) Token: 0x06000118 RID: 280 RVA: 0x0000918D File Offset: 0x0000738D // (set) Token: 0x06000119 RID: 281 RVA: 0x00009195 File Offset: 0x00007395 protected internal byte[] TcpConnectionPrefix { get; set; } // Token: 0x0600011A RID: 282 RVA: 0x0000919E File Offset: 0x0000739E internal void InitOnce() { this.networkSimulationSettings.peerBase = this; } // Token: 0x0600011B RID: 283 internal abstract bool Connect(string serverAddress, string appID, object customData = null); // Token: 0x0600011C RID: 284 public abstract void OnConnect(); // Token: 0x0600011D RID: 285 RVA: 0x000091B0 File Offset: 0x000073B0 private string GetHttpKeyValueString(Dictionary dic) { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair keyValuePair in dic) { stringBuilder.Append(keyValuePair.Key).Append("=").Append(keyValuePair.Value) .Append("&"); } return stringBuilder.ToString(); } // Token: 0x17000056 RID: 86 // (get) Token: 0x0600011E RID: 286 RVA: 0x0000923C File Offset: 0x0000743C protected internal bool IsIpv6 { get { return this.rt != null && this.rt.AddressResolvedAsIpv6; } } // Token: 0x0600011F RID: 287 RVA: 0x00009264 File Offset: 0x00007464 [Obsolete("A IPhotonSocket should set AddressResolvedAsIpv6 as soon as the server's address is resolved and before calling OnConnect.")] public virtual void SetInitIPV6Bit(bool isV6) { bool flag = this.debugOut == DebugLevel.ALL; if (flag) { this.Listener.DebugReturn(DebugLevel.ALL, "Setting IPv6 bit " + isV6.ToString()); } this.rt.AddressResolvedAsIpv6 = isV6; } // Token: 0x06000120 RID: 288 RVA: 0x000092AC File Offset: 0x000074AC internal byte[] PrepareConnectData(string serverAddress, string appID, object custom) { bool flag = this.rt == null || !this.rt.Connected; if (flag) { this.EnqueueDebugReturn(DebugLevel.WARNING, "The peer attempts to prepare an Init-Request but the socket is not connected!?"); } bool flag2 = custom == null; byte[] array4; if (flag2) { byte[] array = new byte[41]; byte[] clientVersion = Version.clientVersion; array[0] = 243; array[1] = 0; array[2] = this.protocol.VersionBytes[0]; array[3] = this.protocol.VersionBytes[1]; array[4] = this.ppeer.ClientSdkIdShifted; array[5] = (byte)(clientVersion[0] << 4) | clientVersion[1]; array[6] = clientVersion[2]; array[7] = clientVersion[3]; array[8] = 0; bool flag3 = string.IsNullOrEmpty(appID); if (flag3) { appID = "LoadBalancing"; } for (int i = 0; i < 32; i++) { array[i + 9] = ((i < appID.Length) ? ((byte)appID[i]) : 0); } bool isIpv = this.IsIpv6; if (isIpv) { byte[] array2 = array; int num = 5; array2[num] |= 128; } else { byte[] array3 = array; int num2 = 5; array3[num2] &= 127; } array4 = array; } else { bool flag4 = custom != null; if (flag4) { Dictionary dictionary = new Dictionary(); dictionary["init"] = null; dictionary["app"] = appID; dictionary["clientversion"] = this.ClientVersion; dictionary["protocol"] = this.protocol.protocolType; dictionary["sid"] = this.ppeer.ClientSdkIdShifted.ToString(); byte[] array5 = null; int num3 = 0; bool flag5 = custom != null; if (flag5) { array5 = this.protocol.Serialize(custom); num3 += array5.Length; } string text = this.GetHttpKeyValueString(dictionary); bool isIpv2 = this.IsIpv6; if (isIpv2) { text += "&IPv6"; } string text2 = string.Format("POST /?{0} HTTP/1.1\r\nHost: {1}\r\nContent-Length: {2}\r\n\r\n", text, serverAddress, num3); byte[] array6 = new byte[text2.Length + num3]; bool flag6 = array5 != null; if (flag6) { Buffer.BlockCopy(array5, 0, array6, text2.Length, array5.Length); } Buffer.BlockCopy(Encoding.UTF8.GetBytes(text2), 0, array6, 0, text2.Length); array4 = array6; } else { array4 = null; } } return array4; } // Token: 0x06000121 RID: 289 RVA: 0x00009520 File Offset: 0x00007720 internal string PepareWebSocketUrl(string serverAddress, string appId, object customData) { StringBuilder stringBuilder = new StringBuilder(1024); string empty = string.Empty; bool flag = customData != null; if (flag) { byte[] array = this.protocol.Serialize(customData); bool flag2 = array == null; if (flag2) { this.EnqueueDebugReturn(DebugLevel.ERROR, "Can not deserialize custom data"); return null; } } stringBuilder.AppendFormat("app={0}&clientver={1}&sid={2}&{3}&initobj={4}", new object[] { appId, this.ClientVersion, this.ppeer.ClientSdkIdShifted, this.IsIpv6 ? "IPv6" : string.Empty, empty }); return stringBuilder.ToString(); } // Token: 0x06000122 RID: 290 internal abstract void Disconnect(); // Token: 0x06000123 RID: 291 internal abstract void StopConnection(); // Token: 0x06000124 RID: 292 internal abstract void FetchServerTimestamp(); // Token: 0x06000125 RID: 293 RVA: 0x000095CC File Offset: 0x000077CC internal bool EnqueueOperation(Dictionary parameters, byte opCode, bool sendReliable, byte channelId, bool encrypted) { return this.EnqueueOperation(parameters, opCode, sendReliable, channelId, encrypted, PeerBase.EgMessageType.Operation); } // Token: 0x06000126 RID: 294 internal abstract bool EnqueueOperation(Dictionary parameters, byte opCode, bool sendReliable, byte channelId, bool encrypted, PeerBase.EgMessageType messageType); // Token: 0x06000127 RID: 295 internal abstract bool DispatchIncomingCommands(); // Token: 0x06000128 RID: 296 internal abstract bool SendOutgoingCommands(); // Token: 0x06000129 RID: 297 RVA: 0x000095EC File Offset: 0x000077EC internal virtual bool SendAcksOnly() { return false; } // Token: 0x0600012A RID: 298 RVA: 0x00009600 File Offset: 0x00007800 internal byte[] SerializeMessageToMessage(object message, bool encrypt, byte[] messageHeader, bool writeLength = true) { StreamBuffer serializeMemStream = this.SerializeMemStream; byte[] array3; lock (serializeMemStream) { this.SerializeMemStream.SetLength(0L); bool flag = !encrypt; if (flag) { this.SerializeMemStream.Write(messageHeader, 0, messageHeader.Length); } bool flag2 = message is byte[]; bool flag3 = flag2; if (flag3) { byte[] array = message as byte[]; this.SerializeMemStream.Write(array, 0, array.Length); } else { this.protocol.SerializeMessage(this.SerializeMemStream, message); } if (encrypt) { byte[] array2 = this.CryptoProvider.Encrypt(this.SerializeMemStream.GetBuffer(), 0, (int)this.SerializeMemStream.Length); this.SerializeMemStream.SetLength(0L); this.SerializeMemStream.Write(messageHeader, 0, messageHeader.Length); this.SerializeMemStream.Write(array2, 0, array2.Length); } array3 = this.SerializeMemStream.ToArray(); } array3[messageHeader.Length - 1] = ((message is byte[]) ? 9 : 8); if (encrypt) { array3[messageHeader.Length - 1] = array3[messageHeader.Length - 1] | 128; } if (writeLength) { int num = 1; Protocol.Serialize(array3.Length, array3, ref num); } return array3; } // Token: 0x0600012B RID: 299 internal abstract byte[] SerializeOperationToMessage(byte opCode, Dictionary parameters, PeerBase.EgMessageType messageType, bool encrypt); // Token: 0x0600012C RID: 300 internal abstract void ReceiveIncomingCommands(byte[] inBuff, int dataLength); // Token: 0x0600012D RID: 301 RVA: 0x00009764 File Offset: 0x00007964 internal void InitCallback() { bool flag = this.peerConnectionState == PeerBase.ConnectionStateValue.Connecting; if (flag) { this.peerConnectionState = PeerBase.ConnectionStateValue.Connected; } this.ApplicationIsInitialized = true; this.FetchServerTimestamp(); this.Listener.OnStatusChanged(StatusCode.Connect); } // Token: 0x17000057 RID: 87 // (get) Token: 0x0600012E RID: 302 RVA: 0x000097A8 File Offset: 0x000079A8 internal static int outgoingStreamBufferSize { get { return PhotonPeer.OutgoingStreamBufferSize; } } // Token: 0x17000058 RID: 88 // (get) Token: 0x0600012F RID: 303 RVA: 0x000097C0 File Offset: 0x000079C0 internal bool IsSendingOnlyAcks { get { return this.ppeer.IsSendingOnlyAcks; } } // Token: 0x17000059 RID: 89 // (get) Token: 0x06000130 RID: 304 RVA: 0x000097E0 File Offset: 0x000079E0 internal int mtu { get { return this.ppeer.MaximumTransferUnit; } } // Token: 0x1700005A RID: 90 // (get) Token: 0x06000131 RID: 305 RVA: 0x00009800 File Offset: 0x00007A00 internal int rhttpMinConnections { get { return this.ppeer.RhttpMinConnections; } } // Token: 0x1700005B RID: 91 // (get) Token: 0x06000132 RID: 306 RVA: 0x00009820 File Offset: 0x00007A20 internal int rhttpMaxConnections { get { return this.ppeer.RhttpMaxConnections; } } // Token: 0x06000133 RID: 307 RVA: 0x00009840 File Offset: 0x00007A40 internal bool ExchangeKeysForEncryption(object lockObject) { this.isEncryptionAvailable = false; bool flag = this.CryptoProvider != null; if (flag) { this.CryptoProvider.Dispose(); this.CryptoProvider = null; } bool flag2 = this.CryptoProvider == null; if (flag2) { this.CryptoProvider = new DiffieHellmanCryptoProvider(); } Dictionary dictionary = new Dictionary(1); dictionary[PhotonCodes.ClientKey] = this.CryptoProvider.PublicKey; bool flag3 = lockObject != null; if (flag3) { lock (lockObject) { return this.EnqueueOperation(dictionary, PhotonCodes.InitEncryption, true, 0, false, PeerBase.EgMessageType.InternalOperationRequest); } } return this.EnqueueOperation(dictionary, PhotonCodes.InitEncryption, true, 0, false, PeerBase.EgMessageType.InternalOperationRequest); } // Token: 0x06000134 RID: 308 RVA: 0x00009908 File Offset: 0x00007B08 internal void DeriveSharedKey(OperationResponse operationResponse) { bool flag = operationResponse.ReturnCode != 0; if (flag) { this.EnqueueDebugReturn(DebugLevel.ERROR, "Establishing encryption keys failed. " + operationResponse.ToStringFull()); this.EnqueueStatusCallback(StatusCode.EncryptionFailedToEstablish); } else { byte[] array = (byte[])operationResponse[PhotonCodes.ServerKey]; bool flag2 = array == null || array.Length == 0; if (flag2) { this.EnqueueDebugReturn(DebugLevel.ERROR, "Establishing encryption keys failed. Server's public key is null or empty. " + operationResponse.ToStringFull()); this.EnqueueStatusCallback(StatusCode.EncryptionFailedToEstablish); } else { this.CryptoProvider.DeriveSharedKey(array); this.isEncryptionAvailable = true; this.EnqueueStatusCallback(StatusCode.EncryptionEstablished); } } } // Token: 0x06000135 RID: 309 RVA: 0x000099B4 File Offset: 0x00007BB4 internal void EnqueueActionForDispatch(PeerBase.MyAction action) { Queue actionQueue = this.ActionQueue; lock (actionQueue) { this.ActionQueue.Enqueue(action); } } // Token: 0x06000136 RID: 310 RVA: 0x000099FC File Offset: 0x00007BFC internal void EnqueueDebugReturn(DebugLevel level, string debugReturn) { Queue actionQueue = this.ActionQueue; lock (actionQueue) { this.ActionQueue.Enqueue(delegate { this.Listener.DebugReturn(level, debugReturn); }); } } // Token: 0x06000137 RID: 311 RVA: 0x00009A68 File Offset: 0x00007C68 internal void EnqueueStatusCallback(StatusCode statusValue) { Queue actionQueue = this.ActionQueue; lock (actionQueue) { this.ActionQueue.Enqueue(delegate { this.Listener.OnStatusChanged(statusValue); }); } } // Token: 0x06000138 RID: 312 RVA: 0x00009ACC File Offset: 0x00007CCC internal virtual void InitPeerBase() { this.protocol = SerializationProtocolFactory.Create(this.ppeer.SerializationProtocolType); this.ppeer.InitializeTrafficStats(); this.ByteCountLastOperation = 0; this.ByteCountCurrentDispatch = 0; this.bytesIn = 0L; this.bytesOut = 0L; this.packetLossByCrc = 0; this.packetLossByChallenge = 0; this.networkSimulationSettings.LostPackagesIn = 0; this.networkSimulationSettings.LostPackagesOut = 0; LinkedList netSimListOutgoing = this.NetSimListOutgoing; lock (netSimListOutgoing) { this.NetSimListOutgoing.Clear(); } LinkedList netSimListIncoming = this.NetSimListIncoming; lock (netSimListIncoming) { this.NetSimListIncoming.Clear(); } this.peerConnectionState = PeerBase.ConnectionStateValue.Disconnected; this.timeBase = SupportClass.GetTickCount(); this.isEncryptionAvailable = false; this.ApplicationIsInitialized = false; this.roundTripTime = 300; this.roundTripTimeVariance = 0; this.packetThrottleInterval = 5000; this.serverTimeOffsetIsAvailable = false; this.serverTimeOffset = 0; } // Token: 0x06000139 RID: 313 RVA: 0x00009BF8 File Offset: 0x00007DF8 internal virtual bool DeserializeMessageAndCallback(byte[] inBuff) { bool flag = inBuff.Length < 2; bool flag3; if (flag) { bool flag2 = this.debugOut >= DebugLevel.ERROR; if (flag2) { this.Listener.DebugReturn(DebugLevel.ERROR, "Incoming UDP data too short! " + inBuff.Length); } flag3 = false; } else { bool flag4 = inBuff[0] != 243 && inBuff[0] != 253; if (flag4) { bool flag5 = this.debugOut >= DebugLevel.ERROR; if (flag5) { this.Listener.DebugReturn(DebugLevel.ALL, "No regular operation UDP message: " + inBuff[0]); } flag3 = false; } else { byte b = inBuff[1] & 127; bool flag6 = (inBuff[1] & 128) > 0; StreamBuffer streamBuffer = null; bool flag7 = b != 1; if (flag7) { try { bool flag8 = flag6; if (flag8) { inBuff = this.CryptoProvider.Decrypt(inBuff, 2, inBuff.Length - 2); streamBuffer = new StreamBuffer(inBuff); } else { streamBuffer = new StreamBuffer(inBuff); streamBuffer.Seek(2L, SeekOrigin.Begin); } } catch (Exception ex) { bool flag9 = this.debugOut >= DebugLevel.ERROR; if (flag9) { this.Listener.DebugReturn(DebugLevel.ERROR, ex.ToString()); } SupportClass.WriteStackTrace(ex); return false; } } int num = 0; switch (b) { case 1: this.InitCallback(); goto IL_345; case 3: { OperationResponse operationResponse = this.protocol.DeserializeOperationResponse(streamBuffer); bool trafficStatsEnabled = this.TrafficStatsEnabled; if (trafficStatsEnabled) { this.TrafficStatsGameLevel.CountResult(this.ByteCountCurrentDispatch); num = SupportClass.GetTickCount(); } this.Listener.OnOperationResponse(operationResponse); bool trafficStatsEnabled2 = this.TrafficStatsEnabled; if (trafficStatsEnabled2) { this.TrafficStatsGameLevel.TimeForResponseCallback(operationResponse.OperationCode, SupportClass.GetTickCount() - num); } goto IL_345; } case 4: { EventData eventData = this.protocol.DeserializeEventData(streamBuffer); bool trafficStatsEnabled3 = this.TrafficStatsEnabled; if (trafficStatsEnabled3) { this.TrafficStatsGameLevel.CountEvent(this.ByteCountCurrentDispatch); num = SupportClass.GetTickCount(); } this.Listener.OnEvent(eventData); bool trafficStatsEnabled4 = this.TrafficStatsEnabled; if (trafficStatsEnabled4) { this.TrafficStatsGameLevel.TimeForEventCallback(eventData.Code, SupportClass.GetTickCount() - num); } goto IL_345; } case 7: { OperationResponse operationResponse = this.protocol.DeserializeOperationResponse(streamBuffer); bool trafficStatsEnabled5 = this.TrafficStatsEnabled; if (trafficStatsEnabled5) { this.TrafficStatsGameLevel.CountResult(this.ByteCountCurrentDispatch); num = SupportClass.GetTickCount(); } bool flag10 = operationResponse.OperationCode == PhotonCodes.InitEncryption; if (flag10) { this.DeriveSharedKey(operationResponse); } else { bool flag11 = operationResponse.OperationCode == PhotonCodes.Ping; if (flag11) { TPeer tpeer = this as TPeer; bool flag12 = tpeer != null; if (flag12) { tpeer.ReadPingResult(operationResponse); } } else { this.EnqueueDebugReturn(DebugLevel.ERROR, "Received unknown internal operation. " + operationResponse.ToStringFull()); } } bool trafficStatsEnabled6 = this.TrafficStatsEnabled; if (trafficStatsEnabled6) { this.TrafficStatsGameLevel.TimeForResponseCallback(operationResponse.OperationCode, SupportClass.GetTickCount() - num); } goto IL_345; } } this.EnqueueDebugReturn(DebugLevel.ERROR, "unexpected msgType " + b); IL_345: flag3 = true; } } return flag3; } // Token: 0x0600013A RID: 314 RVA: 0x00009F64 File Offset: 0x00008164 internal void SendNetworkSimulated(byte[] dataToSend) { bool flag = !this.NetworkSimulationSettings.IsSimulationEnabled; if (flag) { throw new NotImplementedException("SendNetworkSimulated was called, despite NetworkSimulationSettings.IsSimulationEnabled == false."); } bool flag2 = this.usedProtocol == ConnectionProtocol.Udp && this.NetworkSimulationSettings.OutgoingLossPercentage > 0 && this.lagRandomizer.Next(101) < this.NetworkSimulationSettings.OutgoingLossPercentage; if (flag2) { NetworkSimulationSet networkSimulationSet = this.networkSimulationSettings; int lostPackagesOut = networkSimulationSet.LostPackagesOut; networkSimulationSet.LostPackagesOut = lostPackagesOut + 1; } else { int num = ((this.networkSimulationSettings.OutgoingJitter <= 0) ? 0 : (this.lagRandomizer.Next(this.networkSimulationSettings.OutgoingJitter * 2) - this.networkSimulationSettings.OutgoingJitter)); int num2 = this.networkSimulationSettings.OutgoingLag + num; int num3 = SupportClass.GetTickCount() + num2; SimulationItem simulationItem = new SimulationItem { DelayedData = dataToSend, TimeToExecute = num3, Delay = num2 }; LinkedList netSimListOutgoing = this.NetSimListOutgoing; lock (netSimListOutgoing) { bool flag3 = this.NetSimListOutgoing.Count == 0 || this.usedProtocol == ConnectionProtocol.Tcp; if (flag3) { this.NetSimListOutgoing.AddLast(simulationItem); } else { LinkedListNode linkedListNode = this.NetSimListOutgoing.First; while (linkedListNode != null && linkedListNode.Value.TimeToExecute < num3) { linkedListNode = linkedListNode.Next; } bool flag4 = linkedListNode == null; if (flag4) { this.NetSimListOutgoing.AddLast(simulationItem); } else { this.NetSimListOutgoing.AddBefore(linkedListNode, simulationItem); } } } } } // Token: 0x0600013B RID: 315 RVA: 0x0000A114 File Offset: 0x00008314 internal void ReceiveNetworkSimulated(byte[] dataReceived) { bool flag = !this.networkSimulationSettings.IsSimulationEnabled; if (flag) { throw new NotImplementedException("ReceiveNetworkSimulated was called, despite NetworkSimulationSettings.IsSimulationEnabled == false."); } bool flag2 = this.usedProtocol == ConnectionProtocol.Udp && this.networkSimulationSettings.IncomingLossPercentage > 0 && this.lagRandomizer.Next(101) < this.networkSimulationSettings.IncomingLossPercentage; if (flag2) { NetworkSimulationSet networkSimulationSet = this.networkSimulationSettings; int lostPackagesIn = networkSimulationSet.LostPackagesIn; networkSimulationSet.LostPackagesIn = lostPackagesIn + 1; } else { int num = ((this.networkSimulationSettings.IncomingJitter <= 0) ? 0 : (this.lagRandomizer.Next(this.networkSimulationSettings.IncomingJitter * 2) - this.networkSimulationSettings.IncomingJitter)); int num2 = this.networkSimulationSettings.IncomingLag + num; int num3 = SupportClass.GetTickCount() + num2; SimulationItem simulationItem = new SimulationItem { DelayedData = dataReceived, TimeToExecute = num3, Delay = num2 }; LinkedList netSimListIncoming = this.NetSimListIncoming; lock (netSimListIncoming) { bool flag3 = this.NetSimListIncoming.Count == 0 || this.usedProtocol == ConnectionProtocol.Tcp; if (flag3) { this.NetSimListIncoming.AddLast(simulationItem); } else { LinkedListNode linkedListNode = this.NetSimListIncoming.First; while (linkedListNode != null && linkedListNode.Value.TimeToExecute < num3) { linkedListNode = linkedListNode.Next; } bool flag4 = linkedListNode == null; if (flag4) { this.NetSimListIncoming.AddLast(simulationItem); } else { this.NetSimListIncoming.AddBefore(linkedListNode, simulationItem); } } } } } // Token: 0x0600013C RID: 316 RVA: 0x0000A2C4 File Offset: 0x000084C4 protected internal void NetworkSimRun() { for (;;) { bool flag = false; ManualResetEvent netSimManualResetEvent = this.networkSimulationSettings.NetSimManualResetEvent; lock (netSimManualResetEvent) { flag = this.networkSimulationSettings.IsSimulationEnabled; } bool flag2 = !flag; if (flag2) { this.networkSimulationSettings.NetSimManualResetEvent.WaitOne(); } else { LinkedList netSimListIncoming = this.NetSimListIncoming; lock (netSimListIncoming) { while (this.NetSimListIncoming.First != null) { SimulationItem value = this.NetSimListIncoming.First.Value; bool flag3 = value.stopw.ElapsedMilliseconds < (long)value.Delay; if (flag3) { break; } bool flag4 = this.rt != null && this.rt.Connected; if (flag4) { this.ReceiveIncomingCommands(value.DelayedData, value.DelayedData.Length); } this.NetSimListIncoming.RemoveFirst(); } } LinkedList netSimListOutgoing = this.NetSimListOutgoing; lock (netSimListOutgoing) { while (this.NetSimListOutgoing.First != null) { SimulationItem value2 = this.NetSimListOutgoing.First.Value; bool flag5 = value2.stopw.ElapsedMilliseconds < (long)value2.Delay; if (flag5) { break; } bool flag6 = this.rt != null && this.rt.Connected; if (flag6) { this.rt.Send(value2.DelayedData, value2.DelayedData.Length); } this.NetSimListOutgoing.RemoveFirst(); } } Thread.Sleep(0); } } } // Token: 0x0600013D RID: 317 RVA: 0x0000A4B8 File Offset: 0x000086B8 internal void UpdateRoundTripTimeAndVariance(int lastRoundtripTime) { bool flag = lastRoundtripTime < 0; if (!flag) { this.roundTripTimeVariance -= this.roundTripTimeVariance / 4; bool flag2 = lastRoundtripTime >= this.roundTripTime; if (flag2) { this.roundTripTime += (lastRoundtripTime - this.roundTripTime) / 8; this.roundTripTimeVariance += (lastRoundtripTime - this.roundTripTime) / 4; } else { this.roundTripTime += (lastRoundtripTime - this.roundTripTime) / 8; this.roundTripTimeVariance -= (lastRoundtripTime - this.roundTripTime) / 4; } bool flag3 = this.roundTripTime < this.lowestRoundTripTime; if (flag3) { this.lowestRoundTripTime = this.roundTripTime; } bool flag4 = this.roundTripTimeVariance > this.highestRoundTripTimeVariance; if (flag4) { this.highestRoundTripTimeVariance = this.roundTripTimeVariance; } } } // Token: 0x0600013E RID: 318 RVA: 0x0000A59C File Offset: 0x0000879C internal virtual bool InitUdpEncryption(byte[] encryptionSecret, byte[] hmacSecret) { return false; } // Token: 0x0600013F RID: 319 RVA: 0x0000A5AF File Offset: 0x000087AF internal virtual void InitEncryption(byte[] secret) { this.CryptoProvider = new DiffieHellmanCryptoProvider(secret); this.isEncryptionAvailable = true; } // Token: 0x04000069 RID: 105 internal PhotonPeer ppeer; // Token: 0x0400006A RID: 106 internal IProtocol protocol; // Token: 0x0400006B RID: 107 internal ConnectionProtocol usedProtocol; // Token: 0x0400006C RID: 108 internal IPhotonSocket rt; // Token: 0x0400006F RID: 111 internal int ByteCountLastOperation; // Token: 0x04000070 RID: 112 internal int ByteCountCurrentDispatch; // Token: 0x04000071 RID: 113 internal NCommand CommandInCurrentDispatch; // Token: 0x04000072 RID: 114 internal int TrafficPackageHeaderSize; // Token: 0x04000073 RID: 115 internal int packetLossByCrc; // Token: 0x04000074 RID: 116 internal int packetLossByChallenge; // Token: 0x04000075 RID: 117 internal readonly Queue ActionQueue = new Queue(); // Token: 0x04000076 RID: 118 internal short peerID = -1; // Token: 0x04000077 RID: 119 internal PeerBase.ConnectionStateValue peerConnectionState; // Token: 0x04000078 RID: 120 internal int serverTimeOffset; // Token: 0x04000079 RID: 121 internal bool serverTimeOffsetIsAvailable; // Token: 0x0400007A RID: 122 internal int roundTripTime; // Token: 0x0400007B RID: 123 internal int roundTripTimeVariance; // Token: 0x0400007C RID: 124 internal int lastRoundTripTime; // Token: 0x0400007D RID: 125 internal int lowestRoundTripTime; // Token: 0x0400007E RID: 126 internal int lastRoundTripTimeVariance; // Token: 0x0400007F RID: 127 internal int highestRoundTripTimeVariance; // Token: 0x04000080 RID: 128 internal int timestampOfLastReceive; // Token: 0x04000081 RID: 129 internal int packetThrottleInterval; // Token: 0x04000082 RID: 130 internal static short peerCount; // Token: 0x04000083 RID: 131 internal long bytesOut; // Token: 0x04000084 RID: 132 internal long bytesIn; // Token: 0x04000085 RID: 133 internal int commandBufferSize = 100; // Token: 0x04000086 RID: 134 internal ICryptoProvider CryptoProvider; // Token: 0x04000087 RID: 135 private readonly Random lagRandomizer = new Random(); // Token: 0x04000088 RID: 136 internal readonly LinkedList NetSimListOutgoing = new LinkedList(); // Token: 0x04000089 RID: 137 internal readonly LinkedList NetSimListIncoming = new LinkedList(); // Token: 0x0400008A RID: 138 private readonly NetworkSimulationSet networkSimulationSettings = new NetworkSimulationSet(); // Token: 0x0400008B RID: 139 internal Queue CommandLog; // Token: 0x0400008C RID: 140 internal Queue InReliableLog; // Token: 0x0400008D RID: 141 internal object CustomInitData; // Token: 0x0400008E RID: 142 internal string AppId; // Token: 0x04000090 RID: 144 internal int timeBase; // Token: 0x04000091 RID: 145 internal int timeInt; // Token: 0x04000092 RID: 146 internal int timeoutInt; // Token: 0x04000093 RID: 147 internal int timeLastAckReceive; // Token: 0x04000094 RID: 148 internal int timeLastSendAck; // Token: 0x04000095 RID: 149 internal int timeLastSendOutgoing; // Token: 0x04000096 RID: 150 internal const int ENET_PEER_PACKET_LOSS_SCALE = 65536; // Token: 0x04000097 RID: 151 internal const int ENET_PEER_DEFAULT_ROUND_TRIP_TIME = 300; // Token: 0x04000098 RID: 152 internal const int ENET_PEER_PACKET_THROTTLE_INTERVAL = 5000; // Token: 0x04000099 RID: 153 internal bool ApplicationIsInitialized; // Token: 0x0400009A RID: 154 internal bool isEncryptionAvailable; // Token: 0x0400009B RID: 155 internal int outgoingCommandsInStream = 0; // Token: 0x0400009C RID: 156 protected StreamBuffer SerializeMemStream = new StreamBuffer(0); // Token: 0x02000042 RID: 66 // (Invoke) Token: 0x060002D3 RID: 723 internal delegate void MyAction(); // Token: 0x02000043 RID: 67 public enum ConnectionStateValue : byte { // Token: 0x04000196 RID: 406 Disconnected, // Token: 0x04000197 RID: 407 Connecting, // Token: 0x04000198 RID: 408 Connected = 3, // Token: 0x04000199 RID: 409 Disconnecting, // Token: 0x0400019A RID: 410 AcknowledgingDisconnect, // Token: 0x0400019B RID: 411 Zombie } // Token: 0x02000044 RID: 68 internal enum EgMessageType : byte { // Token: 0x0400019D RID: 413 Init, // Token: 0x0400019E RID: 414 InitResponse, // Token: 0x0400019F RID: 415 Operation, // Token: 0x040001A0 RID: 416 OperationResponse, // Token: 0x040001A1 RID: 417 Event, // Token: 0x040001A2 RID: 418 InternalOperationRequest = 6, // Token: 0x040001A3 RID: 419 InternalOperationResponse, // Token: 0x040001A4 RID: 420 Message, // Token: 0x040001A5 RID: 421 RawMessage } } }