OnOpen handler is sometimes called with a huge delay in
TestDataChannel_Open and causes handler_should_be_called_once
failure.
This commit minimizes mutex lock scope around handler registration
and removes redundant mutex.
Also, add sleep before closing PeerConnections in
TestDataChannel_Open to ensure all messages are processed.
DataChannel readyState should be set to Closed on PeerConnection
shutdown. If not properly set it would attempt to interact with
state that doesn't exist after the PeerConnection has been Closed.
Setting the readyState is also clearly defined in the W3C webrtc-pc
Resolves#915
Before we computed DataChannel IDs before signaling, this
is incorrect because IDs must take into account if we are
running an DTLS Client or Server.
This updates the DataChannel ID generation code to take this
into account before generating a streamId.
Resolves#908
In lots of our event handlers we return the event status.
This is so we can know if the callee has finished. In lots
of cases we don't care so get rid of them to simplify the code.
The current dataChannelBufferSize is less than the limit used in
WriteSCTP (called by Send), which means that peers using this
implementations of WebRTC can send messages that will be thrown out by
Read because of an io.ErrShortBuffer error.
In the case that the message is too long, a more appropriate response
would be to close the channel and issue an error rather than log a
warning and continue reading data.
Fire the onOpenHandler immediately if the DataChannel is already open.
This helps prevent race conditions where the DataChannel is opened
before the onOpenHandler is set up, meaning the onopen event is never
received.
Data channel creation checks if the sctp transport is already
established. Because this check was incorrect, in some cases it returned
an error instead of delaying opening the data channel until the sctp
connection is established. Fixed the check. Added locking to
CreateDataChannel to avoid race condition. Added test.
Resolves#478. Adds minimal JavaScript/WASM bindings. This makes it
possible to compile core parts of pions/webrtc to WASM and run it in the
browser. Only data channels are supported for now and there is
limited/no support for certificates and credentials.