static int _m_ReadLength(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Google.Protobuf.CodedInputStream gen_to_be_invoked = (Google.Protobuf.CodedInputStream)translator.FastGetCSObj(L, 1); { int gen_ret = gen_to_be_invoked.ReadLength( ); LuaAPI.xlua_pushinteger(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public override void ReadBlock() { while (true) { // Read Each Tag-Field if (_CodedInputStream.IsAtEnd) { return; } if (_Type == 0) { // Determine the start of a message. while (_Tag == 0) { try { if (_CodedInputStream.IsAtEnd) { return; } _Tag = _CodedInputStream.ReadTag(); } catch (Google.Protobuf.InvalidProtocolBufferException e) { PlatDependant.LogError(e); } catch (InvalidOperationException e) { // this means the stream is closed. so we ignore the exception. //PlatDependant.LogError(e); return; } catch (Exception e) { PlatDependant.LogError(e); return; } } } else { // The Next tag must follow try { _Tag = _CodedInputStream.ReadTag(); if (_Tag == 0) { ResetReadBlockContext(); continue; } } catch (Exception e) { PlatDependant.LogError(e); ResetReadBlockContext(); continue; } } try { // Tag got. int seq = Google.Protobuf.WireFormat.GetTagFieldNumber(_Tag); var ttype = Google.Protobuf.WireFormat.GetTagWireType(_Tag); if (seq == 1 && ttype == Google.Protobuf.WireFormat.WireType.Varint) { ResetReadBlockContext(); _Type = _CodedInputStream.ReadUInt32(); } else if (_Type != 0) { if (seq == 2 && ttype == Google.Protobuf.WireFormat.WireType.Varint) { _Flags = _CodedInputStream.ReadUInt32(); } else if (seq == 3 && ttype == Google.Protobuf.WireFormat.WireType.Varint) { _Seq = _CodedInputStream.ReadUInt32(); } else if (seq == 4 && ttype == Google.Protobuf.WireFormat.WireType.Varint) { _SSeq = _CodedInputStream.ReadUInt32(); } else if (seq == 5 && ttype == Google.Protobuf.WireFormat.WireType.LengthDelimited) { _Size = _CodedInputStream.ReadLength(); if (_Size >= 0) { if (_Size > CONST.MAX_MESSAGE_LENGTH) { PlatDependant.LogError("We got a too long message. We will drop this message and treat it as an error message."); _CodedInputStream.SkipRawBytes(_Size); FireReceiveBlock(null, 0, _Type, _Flags, _Seq, _SSeq); } else { _ReadBuffer.Clear(); _CodedInputStream.ReadRawBytes(_ReadBuffer, _Size); FireReceiveBlock(_ReadBuffer, _Size, _Type, _Flags, _Seq, _SSeq); } } else { FireReceiveBlock(null, 0, _Type, _Flags, _Seq, _SSeq); } ResetReadBlockContext(); return; } } // else means the first field(type) has not been read yet. _Tag = 0; } catch (InvalidOperationException e) { // this means the stream is closed. so we ignore the exception. //PlatDependant.LogError(e); return; } catch (Exception e) { PlatDependant.LogError(e); ResetReadBlockContext(); } } }