Skip to content

swarm with ffi #4269

Closed Answered by thomaseizinger
blackshadowsoftwareltd asked this question in Q&A
Discussion options

You must be logged in to vote

My advice from above still stands:

I'd recommend to restructure your code such that you have a single event loop that:

  • polls a channel for incoming messages
  • polls the swarm for events

You can then create FFI functions to send messages into that channel.

You should extend your listen_event function to also poll the receiver-end of a channel. You can store the sender-end in a static variable like you do with some of the other state.

You can then create an FFI function that accesses that Sender and sends the parameters as a message into it. The message will be received by the Receiver within the event-loop where you can pass it to the Swarm.

See https://github.com/libp2p/rust-libp2p/blob…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@canewsin
Comment options

@thomaseizinger
Comment options

@blackshadowsoftwareltd
Comment options

@thomaseizinger
Comment options

Answer selected by blackshadowsoftwareltd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants