Skip to content

Implementing custom application protocols #3764

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

You must be logged in to vote

If your protocol is request-response style, you can use libp2p-request-response.

If it is not, you will have to implement the following traits on various structs:

  • ConnectionHandler to do the state management per connection
  • NetworkBehaviour to do the state management across your entire protocol

For a simple protocol such as answering the current time, that state is available "inline" with the request, meaning you can directly answer it in the stream upgrade (look at InboundUpgrade trait and how it is used).

However, for more complex state management, you want to use ReadyUpgrade, pass the stream to the ConnectionHandler and read and write to it there.

Have a look at how these traits are …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@pieterdd
Comment options

@pieterdd
Comment options

@thomaseizinger
Comment options

@thomaseizinger
Comment options

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