void demo_csgo::handle_netmessages(google::protobuf::io::CodedInputStream& cis) { if(this->netmessage_callbacks[msg_type].empty()) { cis.Skip(cis.BytesUntilLimit()); return; } T msg; if(!msg.MergeFromCodedStream(&cis)) { std::cerr << "handle_netmessages<" << typeid(T).name() << ">(): !msg.MergeFromCodedStream(&cis)" << std::endl; return; } for(auto f : this->netmessage_callbacks[msg_type]) { f(&msg); } }
bool Connection::dequeue(MessageType type, ::google::protobuf::io::CodedInputStream &stream) { bool res; T msg; uint32_t length; if (!stream.ReadVarint32(&length)) return false; uint32_t bytesLeft = stream.BytesUntilLimit(); if (length > bytesLeft) return false; ::google::protobuf::io::CodedInputStream::Limit limit = stream.PushLimit(length); if ((res = msg.MergePartialFromCodedStream(&stream))) { message(type, msg); } stream.PopLimit(limit); return res; }