Beispiel #1
0
QByteArray OsmPbfWriterPrivate::packPbfMessageToArray( const google::protobuf::MessageLite &message)
{
    QByteArray result;
    result.resize(message.ByteSize());
    if (!message.SerializeToArray(result.data(), result.size()))
        throw OsmPbfWriter::SerializeException();
    return result;
}
Beispiel #2
0
  int HUServer::hu_aap_unenc_send_message(int retry, int chan, uint16_t messageCode, const google::protobuf::MessageLite& message, int overrideTimeout)
  {
    const int messageSize = message.ByteSize();
    const int requiredSize = messageSize + 2;
    if (temp_assembly_buffer.size() < requiredSize)
    {
      temp_assembly_buffer.resize(requiredSize);
    }

    uint16_t* destMessageCode = reinterpret_cast<uint16_t*>(temp_assembly_buffer.data());
    *destMessageCode++ = htobe16(messageCode);

    if (!message.SerializeToArray(destMessageCode, messageSize))
    {
      loge("AppendToString failed for %s", message.GetTypeName().c_str());
      return -1;
    }

    logd ("Send %s on channel %i %s", message.GetTypeName().c_str(), chan, chan_get(chan));
    //hex_dump("PB:", 80, temp_assembly_buffer.data(), requiredSize);
    return hu_aap_unenc_send(retry, chan, temp_assembly_buffer.data(), requiredSize, overrideTimeout);
  }
Beispiel #3
0
void ldbDebugServer::sendPacket(ENetPeer* peer, const google::protobuf::MessageLite& msg) {
    auto packet = enet_packet_create(nullptr, msg.ByteSize(), ENET_PACKET_FLAG_RELIABLE);
    msg.SerializeToArray(packet->data, packet->dataLength);
    ldb_mutexsentry sentry(packetMtx_);
    packetsToSend_.emplace_back(peer, packet);
}