I want to know who sent the messages when retrieved from the pubnub.history!
pubnub.history() only returns timetoken and the message.
The sender (publisher) UUID is provided in the message you receive in realtime as a subscriber, but PubNub only stores the actual message
you published along with any meta
data that provided:
PubNub JavaScript SDK publish docs sample code
pubnub.publish(
{
channel: 'my_channel',
message: {
such: 'object'
},
meta: {
"cool": "meta"
}
},
function (status, response) {
if (status.error) {
// handle error
console.log(status)
} else {
console.log("message Published w/ timetoken", response.timetoken)
}
}
);
Best practice would be to add the publisher's UUID to the meta
parameter which will not only allow you to get this value using history
API, but you can also use it to filter out messages that the client has sent (don't receive your own messages using Stream Filter).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With