nim-libp2p
nim-libp2p copied to clipboard
Add streaming protocol tutorial, fix tutorial #2 early conn termination
Add a tutorial that shows how to create a streaming protocol.
In the second tutorial, the connection was being terminated too quickly in main
, before the server had a chance to echo. By adding a connection read on the client side (in hello
), we wait for the server to echo the message it received and respond back before closing the connection.
~~NOTE: This PR is based on the branch fix/switch-start-return-futs
from PR #662. That PR should likely be merged first, then we can rebase this branch on top of unstable
.~~
You can also add a link to your tutorial at the end of the second one, and add it to the CI in libp2p.nimble
Fixed up.
Also changed the way the stream checks atEof
using readOnce
instead of readLp
and adjusted the comments and tutorial explanation to suit.
Updated tutorial 3 (streaming tutorial) to remove readLp/writeLp
in combo with atEof
, and instead using write
, readOnce
, and atEof
.
I think 90% of users will use the Lp variants, but since we already show it in tutorial 2, it may make sense to show the non-Lp here But it should be clear that Lp can of be used for streaming as well, since it's about what everybody does
I think 90% of users will use the Lp variants, but since we already show it in tutorial 2, it may make sense to show the non-Lp here But it should be clear that Lp can of be used for streaming as well, since it's about what everybody does
I'll make tutorial #3 a streaming tutorial with readLp/writeLp
and LPStreamEOFError
, then we can make a fourth with read/write
and atEof
.
Should've updated this sooner, added a fourth tutorial as per above comment.
Is there anything blocking this? LGTM