-
Notifications
You must be signed in to change notification settings - Fork 950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an example showcasing how to implement a custom network behavior and access streams #4983
Conversation
I'm trying to understand how to implement
|
We still want to use
Something along the lines of:
The main thing we want to achieve is not having users use the Let me know if that makes sense! :) |
examples/escape-hatch/src/lib.rs
Outdated
|
||
impl Behaviour { | ||
pub fn new(protocol: StreamProtocol) -> (Self, Control, IncomingStreams) { | ||
let (sender, receiver) = mpsc::channel::<StreamMessage>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The receiver
needs to go into Behaviour
so you can call poll_next
on it and actually act on the message from the Control
.
if let Some(e) = self.events.pop_back() { | ||
} else { | ||
} | ||
|
||
todo!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to Control::open_stream
, this needs to listen on an mpsc::Receiver
where the mpsc::Sender
lives in Behaviour
. Any inbound streams from the ConnectionHandler
need to be sent this one.
@eserilev Let me know what your appetite is for continuing to work on this. I'll be stepping down as a maintainer soon and offering this capability is something that would be great to land as a final action. If you are okay with it, I'd be happy to take over from here :) |
@thomaseizinger feel free to take it from here, thanks for all the help!! |
Okay, thanks! |
Going to close this for now and start my own branch. |
Continuing here: #5027. |
Description
#4457
An example that serves as a copy past-able snippet for users that want to access a stream. Also documents how to implement a custom network behavior.
The example should:
Notes & open questions
This is currently a draft PR, I will add more details as my work progresses
Change checklist