'message' event should contain 'topicCIDs' array when emitted from _handleDirectConnection()
See original GitHub issueHey, I started looking into if we can use this module in orbit-db to achieve what @diasdavid suggested some time ago, to handle the “send first message automatically upon connecting to a peer” (it seems we can! 🎉 ❤️)
In orbit-db’s pubsub wrapper, we’re relying on the topicCIDs
array that is part of the message that is received from pubsub. And it’s present in the messages ipfs-pubsub-room emits when messages are received as a “broadcast” but not when they’re sent directly to a peer with sendTo()
.
I took a look at the code and it looks to me that this is the place where we’re missing the the topicCIDs
array: https://github.com/ipfs-shipyard/ipfs-pubsub-room/blob/master/src/index.js#L138. Ie. to fix it, we should add topicCIDs: [ this._topic ]
on line 141:
pull.map((message) => {
this.emit('message', {
from: peerId,
data: message,
topicCIDs: [ this._topic ]
})
return message
}),
I started to write a PR, but unfortunately the tests are not running. I’d be happy to PR the fix.
Would you agree this is the right fix? Did I miss anything?
@pgte I love how this module exposes the ‘peer joined’ and ‘peer left’ events as well as gives us direct access to send a message to a specific peer. Thank you for writing it! ❤️
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Correct. I don’t see anywhere else that needs this…
Cool, ok, so the fix should then be to add here:
topicCIDs
(array) to the direct messageseqno
(Buffer) to the direct message@pgte correct? Are there other places that need the same fix?