示例#1
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);
  }
示例#2
0
void ENetEndpoint::sDefaultMessageHandler(ENetEndpoint& endpoint,
                                          const google::protobuf::MessageLite& message) {
  std::cout << endpoint.getIdentifier() << " No handler for: " 
            << message.GetTypeName() << std::endl;
}