public object Deserialize(byte[] serializedData) { StreamBuffer streamBuffer = new StreamBuffer(serializedData); return(this.Deserialize(streamBuffer, streamBuffer.ReadByteAsByte())); }
public object DeserializeMessage(StreamBuffer stream) { return(this.Deserialize(stream, stream.ReadByteAsByte())); }
internal virtual bool DeserializeMessageAndCallback(StreamBuffer stream) { if (stream.IntLength < 2) { if ((int)this.debugOut >= 1) { this.Listener.DebugReturn(DebugLevel.ERROR, "Incoming UDP data too short! " + stream.IntLength); } return(false); } byte b = stream.ReadByteAsByte(); if (b != 243 && b != 253) { if ((int)this.debugOut >= 1) { this.Listener.DebugReturn(DebugLevel.ALL, "No regular operation UDP message: " + b); } return(false); } byte b2 = stream.ReadByteAsByte(); byte b3 = (byte)(b2 & 0x7F); bool flag = (b2 & 0x80) > 0; if (b3 != 1) { try { if (flag) { byte[] buf = this.CryptoProvider.Decrypt(stream.GetBuffer(), 2, stream.IntLength - 2); stream = new StreamBuffer(buf); } else { stream.Seek(2L, SeekOrigin.Begin); } } catch (Exception ex) { if ((int)this.debugOut >= 1) { this.Listener.DebugReturn(DebugLevel.ERROR, "msgType: " + b3 + " exception: " + ex.ToString()); } SupportClass.WriteStackTrace(ex); return(false); } } if (FullLogging) { Listener.DebugReturn(DebugLevel.ERROR, SupportClass.StreamBufferToString(stream)); } int num = 0; switch (b3) { case 3: { OperationResponse operationResponse = this.SerializationProtocol.DeserializeOperationResponse(stream); if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.CountResult(this.ByteCountCurrentDispatch); num = SupportClass.GetTickCount(); } this.Listener.OnOperationResponse(operationResponse); if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.TimeForResponseCallback(operationResponse.OperationCode, SupportClass.GetTickCount() - num); } break; } case 4: { try { EventData eventData = this.SerializationProtocol.DeserializeEventData(stream, this.reusableEventData); if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.CountEvent(this.ByteCountCurrentDispatch); num = SupportClass.GetTickCount(); } this.Listener.OnEvent(eventData); if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.TimeForEventCallback(eventData.Code, SupportClass.GetTickCount() - num); } if (this.photonPeer.ReuseEventInstance) { this.reusableEventData = eventData; } } catch (Exception e) { if (debugOut >= DebugLevel.INFO) { this.EnqueueDebugReturn(DebugLevel.ERROR, "Received abnormal EventData: " + e.Message + "\nException: " + e.StackTrace); } return(true); } break; } case 1: this.InitCallback(); break; case 7: { OperationResponse operationResponse = this.SerializationProtocol.DeserializeOperationResponse(stream); if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.CountResult(this.ByteCountCurrentDispatch); num = SupportClass.GetTickCount(); } if (operationResponse.OperationCode == PhotonCodes.InitEncryption) { this.DeriveSharedKey(operationResponse); } else if (operationResponse.OperationCode == PhotonCodes.Ping) { TPeer tPeer = this as TPeer; if (tPeer != null) { tPeer.ReadPingResult(operationResponse); } } else { this.EnqueueDebugReturn(DebugLevel.ERROR, "Received unknown internal operation. " + operationResponse.ToStringFull()); } if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.TimeForResponseCallback(operationResponse.OperationCode, SupportClass.GetTickCount() - num); } break; } case 8: { object obj = this.SerializationProtocol.DeserializeMessage(stream); if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.CountEvent(this.ByteCountCurrentDispatch); num = SupportClass.GetTickCount(); } if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.TimeForMessageCallback(SupportClass.GetTickCount() - num); } break; } case 9: { if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.CountEvent(this.ByteCountCurrentDispatch); num = SupportClass.GetTickCount(); } byte[] array = stream.ToArrayFromPos(); if (this.TrafficStatsEnabled) { this.TrafficStatsGameLevel.TimeForRawMessageCallback(SupportClass.GetTickCount() - num); } break; } default: this.EnqueueDebugReturn(DebugLevel.ERROR, "unexpected msgType " + b3); break; } return(true); }