Skip to content
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

Async UPnP and Echo service #158

Closed
wants to merge 14 commits into from

Conversation

lionel-faber
Copy link
Contributor

No description provided.

@lionel-faber lionel-faber requested a review from a team as a code owner October 1, 2020 11:17
Copy link
Contributor

@bochaco bochaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider if it's possible to remove the feature upnp as it make the code more unreadable and perhaps it's over killing, perhaps we just need a function which is specific for using upnp for discovering the public address, and the consumer of the api decides to call it if that's what it needs.

}
}

// Helper to read the message's bytes from the provided stream
async fn read_bytes(recv: &mut quinn::RecvStream) -> Result<WireMsg> {
Copy link
Contributor

@bochaco bochaco Oct 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we really should do this, we are adding a function which has one line of code, so we are not re-using code really, and it's having more lines of code but no gain, calling WireMsg::read_from_stream(recv).await should be good enough from wherever it's needed, and it should be self-explanatory already, if not, then we can rename read_from_stream to make it self-explanatory.

Ok(WireMsg::EndpointEchoReq) => {
let message = WireMsg::EndpointEchoResp(peer_addr);
message.write_to_stream(&mut send).await.ok()?;
None
Copy link
Contributor

@bochaco bochaco Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't return None in this case as that would mean for the user that there won't be more messages arriving in the stream, and therefore the user will end the loop. We should send the echo response, but then go back and read the next message by continuing the loop, so if next message is for the user it will receive it as thee next message without noticing there was an echo response sent in beforehand.

}
Ok(msg) => {
error!("Unexpected message type: {:?}", msg);
None
Copy link
Contributor

@bochaco bochaco Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment, we should log the error but we shouldn't return None, instead read next message by continuing the loop.

from stream error occours so that the client can continue the loop for
other messages
@lionel-faber lionel-faber force-pushed the upnp-async branch 2 times, most recently from 975b6ad to 620f63f Compare October 23, 2020 07:30
@lionel-faber
Copy link
Contributor Author

These changes are incorporated in #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants