public override bool Decode(NetworkBuffer msgBuffer, ref int msgCount) { bool result; if (msgBuffer.ReadableBytes < lengthFieldEndOffset) { result = false; } else { int offset = msgBuffer.ReadOffset + lengthFieldOffset; int num; switch (lengthFieldLength) { case 1: num = msgBuffer.GetByte(offset); goto IL_7A; case 2: num = msgBuffer.GetUInt16(offset); goto IL_7A; case 4: num = msgBuffer.GetInt32(offset); goto IL_7A; } throw new Exception("should not reach here"); IL_7A: if (num < 0) { msgBuffer.SkipBytes(lengthFieldEndOffset); throw new Exception("negative pre-adjustment length field: " + num); } num += lengthAdjustment + lengthFieldEndOffset; if (num < lengthFieldEndOffset) { msgBuffer.SkipBytes(lengthFieldEndOffset); throw new Exception(string.Concat(new object[] { "Adjusted frame length (", num, ") is less than lengthFieldEndOffset: ", lengthFieldEndOffset })); } if (num > maxFrameLength) { tooLongFrameLength = (long)num; bytesToDiscard = (long)(num - msgBuffer.ReadableBytes); msgBuffer.SkipBytes(msgBuffer.ReadableBytes); throw new Exception(string.Format("too long frame, frame length:{0}", tooLongFrameLength)); } int num2 = num; if (msgBuffer.ReadableBytes < num2) { LoggerManager.Instance.Info("msgBuffer.ReadableBytes {0} < frameLengthInt {1}", msgBuffer.ReadableBytes, num2); result = false; } else { if (initialBytesToStrip > num2) { msgBuffer.SkipBytes(num2); throw new Exception(string.Concat(new object[] { "Adjusted frame length (", num, ") is less than initialBytesToStrip: ", initialBytesToStrip })); } msgBuffer.SkipBytes(initialBytesToStrip); msgCount = num2 - initialBytesToStrip; result = true; } } return(result); }