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

Implement datachannel close #24

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

mo3rfan
Copy link
Contributor

@mo3rfan mo3rfan commented Apr 6, 2017

No description provided.

Sets SCTP_RESET_STREAMS on the socket to close
the datachannel.
@mo3rfan mo3rfan force-pushed the datachannel_close branch from cf74be8 to 6f98e0e Compare April 6, 2017 12:31
Copy link
Owner

@chadnickbok chadnickbok left a comment

Choose a reason for hiding this comment

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

Great work, thank you so much. A few things I'd like cleaned up before its time to merge.

I'll try to take some time this evening to more thoroughly review and test out this PR.

@@ -98,6 +98,42 @@ void SCTPWrapper::OnNotification(union sctp_notification *notify, size_t len) {
break;
case SCTP_STREAM_RESET_EVENT:
SPDLOG_TRACE(logger, "OnNotification(type=SCTP_STREAM_RESET_EVENT)");
struct sctp_stream_reset_event reset_event;
reset_event = notify->sn_strreset_event;
for (int i = 1; i < 2; i++) {
Copy link
Owner

Choose a reason for hiding this comment

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

Lets drop the for here - we're only closing one data channel at a time.

Alternatively, if the sctp_stream_reset_event can actually hold multiple streams to reset, lets loop across all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The event could hold multiple streams as it's a list. I would ideally want to loop across each of them, but I'm not sure how to do that without knowing the size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix in 289b7ef

void HandleStringMessage(ChunkPtr chunk, uint16_t sid);
void HandleBinaryMessage(ChunkPtr chunk, uint16_t sid);

std::shared_ptr<Logger> logger = GetLogger("rtcdcpp.PeerConnection");
public:
void ResetSCTPStream(uint16_t stream_id);
Copy link
Owner

Choose a reason for hiding this comment

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

I'd like to hide the specifics of resetting streams inside the DataChannel - the PeerConnection here is meant to be a somewhat close mirror of the Javascript DataChannel API, which doesn't expose SCTP directly.

Copy link
Contributor Author

@mo3rfan mo3rfan Apr 6, 2017

Choose a reason for hiding this comment

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

I agree! I shouldn't expose this. Will fix soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 91db2d4. Let me know if this is okay.

logger->info("Outgoing stream_id#{} have been reset, calling onClose CB", streamid);
const uint8_t dc_close_data = DC_TYPE_CLOSE;
const uint8_t *dc_close_ptr = &dc_close_data;
OnMsgReceived(dc_close_ptr, sizeof(dc_close_ptr), streamid + 1, PPID_CONTROL);
Copy link
Owner

Choose a reason for hiding this comment

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

why is this streamid + 1

Copy link
Contributor Author

@mo3rfan mo3rfan Apr 6, 2017

Choose a reason for hiding this comment

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

Fixed in 55b64e1

mo3rfan and others added 4 commits April 7, 2017 12:25
Also fixes the function prototype.
This is computed from strreset_length field from
sctp_stream_reset_event struct. This field is the
total length in bytes of the delivered event,
including the header.

https://tools.ietf.org/html/rfc6525#section-6.1.1
@mo3rfan mo3rfan closed this May 10, 2017
@mo3rfan
Copy link
Contributor Author

mo3rfan commented Aug 31, 2017

Requires #30 and #32 to be merged first in order to compile this error free.

@mo3rfan mo3rfan reopened this Aug 31, 2017
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