Presence, PubNub + Ruby
-
12-12-2019 - |
Question
I'm trying to use the presence features of PubNub and relay the info received back as a normal message. Below is my subscribe function that is working properly as well as my here_now that doesn't give me anything. I guess what I'm wondering is how and why they differ. Pointers on proper implementation are also of great value.
pubnub.here_now({
'channel' => @channel,
'callback' => lambda do |x|
## Relay Message
sendMessage(x)
return true
end
})
pubnub.subscribe({
'channel' => @channel,
'callback' => lambda do |message|
## Relay Message
sendMessage(message)
return true
end
})
Solution
For very simple test with what you have provided, you will want to run the subscribe in one ruby script, first, then run the publish script in the here_now script separately.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow