using System; using System.Collections.Generic; namespace ExitGames.Client.Photon { // Token: 0x02000027 RID: 39 public class Protocol { // Token: 0x060001CB RID: 459 RVA: 0x0000F380 File Offset: 0x0000D580 public static bool TryRegisterType(Type type, byte typeCode, SerializeMethod serializeFunction, DeserializeMethod deserializeFunction) { bool flag = Protocol.CodeDict.ContainsKey(typeCode) || Protocol.TypeDict.ContainsKey(type); bool flag2; if (flag) { flag2 = false; } else { CustomType customType = new CustomType(type, typeCode, serializeFunction, deserializeFunction); Protocol.CodeDict.Add(typeCode, customType); Protocol.TypeDict.Add(type, customType); flag2 = true; } return flag2; } // Token: 0x060001CC RID: 460 RVA: 0x0000F3DC File Offset: 0x0000D5DC public static bool TryRegisterType(Type type, byte typeCode, SerializeStreamMethod serializeFunction, DeserializeStreamMethod deserializeFunction) { bool flag = Protocol.CodeDict.ContainsKey(typeCode) || Protocol.TypeDict.ContainsKey(type); bool flag2; if (flag) { flag2 = false; } else { CustomType customType = new CustomType(type, typeCode, serializeFunction, deserializeFunction); Protocol.CodeDict.Add(typeCode, customType); Protocol.TypeDict.Add(type, customType); flag2 = true; } return flag2; } // Token: 0x060001CD RID: 461 RVA: 0x0000F438 File Offset: 0x0000D638 [Obsolete] public static byte[] Serialize(object obj) { bool flag = Protocol.ProtocolDefault == null; if (flag) { Protocol.ProtocolDefault = new Protocol16(); } IProtocol protocolDefault = Protocol.ProtocolDefault; byte[] array; lock (protocolDefault) { array = Protocol.ProtocolDefault.Serialize(obj); } return array; } // Token: 0x060001CE RID: 462 RVA: 0x0000F494 File Offset: 0x0000D694 [Obsolete] public static object Deserialize(byte[] serializedData) { bool flag = Protocol.ProtocolDefault == null; if (flag) { Protocol.ProtocolDefault = new Protocol16(); } IProtocol protocolDefault = Protocol.ProtocolDefault; object obj; lock (protocolDefault) { obj = Protocol.ProtocolDefault.Deserialize(serializedData); } return obj; } // Token: 0x060001CF RID: 463 RVA: 0x0000F4F0 File Offset: 0x0000D6F0 public static void Serialize(short value, byte[] target, ref int targetOffset) { int num = targetOffset; targetOffset = num + 1; target[num] = (byte)(value >> 8); num = targetOffset; targetOffset = num + 1; target[num] = (byte)value; } // Token: 0x060001D0 RID: 464 RVA: 0x0000F51C File Offset: 0x0000D71C public static void Serialize(int value, byte[] target, ref int targetOffset) { int num = targetOffset; targetOffset = num + 1; target[num] = (byte)(value >> 24); num = targetOffset; targetOffset = num + 1; target[num] = (byte)(value >> 16); num = targetOffset; targetOffset = num + 1; target[num] = (byte)(value >> 8); num = targetOffset; targetOffset = num + 1; target[num] = (byte)value; } // Token: 0x060001D1 RID: 465 RVA: 0x0000F568 File Offset: 0x0000D768 public static void Serialize(float value, byte[] target, ref int targetOffset) { float[] array = Protocol.memFloatBlock; lock (array) { Protocol.memFloatBlock[0] = value; Buffer.BlockCopy(Protocol.memFloatBlock, 0, target, targetOffset, 4); } bool isLittleEndian = BitConverter.IsLittleEndian; if (isLittleEndian) { byte b = target[targetOffset]; byte b2 = target[targetOffset + 1]; target[targetOffset] = target[targetOffset + 3]; target[targetOffset + 1] = target[targetOffset + 2]; target[targetOffset + 2] = b2; target[targetOffset + 3] = b; } targetOffset += 4; } // Token: 0x060001D2 RID: 466 RVA: 0x0000F5F8 File Offset: 0x0000D7F8 public static void Deserialize(out int value, byte[] source, ref int offset) { int num = offset; offset = num + 1; int num2 = (int)source[num] << 24; num = offset; offset = num + 1; int num3 = num2 | ((int)source[num] << 16); num = offset; offset = num + 1; int num4 = num3 | ((int)source[num] << 8); num = offset; offset = num + 1; value = num4 | (int)source[num]; } // Token: 0x060001D3 RID: 467 RVA: 0x0000F640 File Offset: 0x0000D840 public static void Deserialize(out short value, byte[] source, ref int offset) { int num = offset; offset = num + 1; byte b = (byte)(source[num] << 8); num = offset; offset = num + 1; value = (short)(b | source[num]); } // Token: 0x060001D4 RID: 468 RVA: 0x0000F66C File Offset: 0x0000D86C public static void Deserialize(out float value, byte[] source, ref int offset) { bool isLittleEndian = BitConverter.IsLittleEndian; if (isLittleEndian) { byte[] array = Protocol.memDeserialize; lock (array) { byte[] array2 = Protocol.memDeserialize; byte[] array3 = array2; int num = 3; int num2 = offset; offset = num2 + 1; array3[num] = source[num2]; byte[] array4 = array2; int num3 = 2; num2 = offset; offset = num2 + 1; array4[num3] = source[num2]; byte[] array5 = array2; int num4 = 1; num2 = offset; offset = num2 + 1; array5[num4] = source[num2]; byte[] array6 = array2; int num5 = 0; num2 = offset; offset = num2 + 1; array6[num5] = source[num2]; value = BitConverter.ToSingle(array2, 0); } } else { value = BitConverter.ToSingle(source, offset); offset += 4; } } // Token: 0x0400011B RID: 283 internal static readonly Dictionary TypeDict = new Dictionary(); // Token: 0x0400011C RID: 284 internal static readonly Dictionary CodeDict = new Dictionary(); // Token: 0x0400011D RID: 285 private static IProtocol ProtocolDefault; // Token: 0x0400011E RID: 286 private static readonly float[] memFloatBlock = new float[1]; // Token: 0x0400011F RID: 287 private static readonly byte[] memDeserialize = new byte[4]; } }