question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'message' event should contain 'topicCIDs' array when emitted from _handleDirectConnection()

See original GitHub issue

Hey, 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pgtecommented, Oct 30, 2017

Correct. I don’t see anywhere else that needs this…

0reactions
haadcodecommented, Oct 30, 2017

Cool, ok, so the fix should then be to add here:

  • add topicCIDs(array) to the direct message
  • add seqno (Buffer) to the direct message

@pgte correct? Are there other places that need the same fix?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ServiceWorkerGlobalScope: message event - Web APIs | MDN
Returns the array containing the MessagePort objects representing the ports of the associated message channel. Examples. In the below example a ...
Read more >
Working with messages - Node-RED
When displaying an Array or Object, the sidebar provides a structured view that can be used to explore the message. At the top...
Read more >
Attach Event Listener to Array for Push() Event - Stack Overflow
Once my script loads, it execute the commands. The problems is, the user may push additional commands onto the array after my script...
Read more >
Dead letter and retry policies - Azure Event Grid
The dead letter blobs created will contain one or more events in an array, which is an important behavior to consider when processing...
Read more >
message event - Slack API
Message subtypes. Unlike other event types, message events can have a subtype. For example, this is a channel join message: { ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found