Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
// pass a pointer to Notify along with the size 
m_Comms.Notify( "ACOMMS_TRANSMIT_DATA", &packet[0], packet.size() );


// convert to a string and pass to Norify
m_Comms.Notify( "ACOMMS_TRANSMIT_DATA", string( (char*) &packet[0], packet.size() ) );

Notify will actually use the exact string constructor in the 2nd method if you pass it a pointer, so these two methods are identical.  To get your data from ACOMMS_RECEIVED_DATA:

Code Block

// say we did something like this in OnNewMail
string msg_string = msg.GetString();

// the .data() method gives us a pointer to the string's data in contiguous memory
memcpy(&data_received.packet_id, msg_string.data(), msg_string.size());