Interface IModuleOnWebRTCDataChannel
IModuleOnWebRTCDataChannel: method interface examples for the WebRTC data-channel module methods.
Since module methods must be implemented as instance methods on the module class, a module does not implement this interface. This interface only serves as an example of the method names and call signatures needed to implement these methods.
These methods fire only when the application enables data channels
(webrtcEnableDataChannels) with the data-channel mode set to module
(webrtcDataChannelMode). For one peer connection the callbacks are serialized and ordered:
session create, then per channel open, its messages in arrival order and close, then session destroy
exactly once. No callback fires for a channel after its close. Different peer connections dispatch
concurrently.
These methods must return promptly; hand slow work to your own executor. They run on a bounded pool
shared by every module-mode connection, so a callback that blocks delays unrelated connections, and
inbound messages queued beyond webrtcDataChannelMaxPendingDispatchMessages are dropped with a
warning.
-
Method Summary
Modifier and TypeMethodDescriptionvoidonWebRTCDataChannelBinaryMessage(IWebRTCDataChannel channel, byte[] message) Invoked when a binary message arrives on a channel.voidInvoked exactly once when a channel closes, whether the client closed it, a module closed it viaIWebRTCDataChannel.close(), or the connection was torn down.voidInvoked when a channel becomes usable, whether the client opened it (IWebRTCDataChannel.isRemotelyOpened()true) or a module opened it viaIWebRTCDataChannelSession.openChannel(String).voidInvoked when a peer connection's SCTP association is up and data channels can flow.voidInvoked once when a peer connection's data-channel session is torn down (connection close or SCTP disassociation), after every open channel has reported close.voidonWebRTCDataChannelStringMessage(IWebRTCDataChannel channel, String message) Invoked when a string message arrives on a channel.
-
Method Details
-
onWebRTCDataChannelSessionCreate
Invoked when a peer connection's SCTP association is up and data channels can flow. Channels can be opened toward the client from here on viaIWebRTCDataChannelSession.openChannel(String).- Parameters:
session- data-channel session
-
onWebRTCDataChannelSessionDestroy
Invoked once when a peer connection's data-channel session is torn down (connection close or SCTP disassociation), after every open channel has reported close.- Parameters:
session- data-channel session
-
onWebRTCDataChannelOpen
Invoked when a channel becomes usable, whether the client opened it (IWebRTCDataChannel.isRemotelyOpened()true) or a module opened it viaIWebRTCDataChannelSession.openChannel(String).- Parameters:
channel- data channel
-
onWebRTCDataChannelStringMessage
Invoked when a string message arrives on a channel. Each call carries one whole message.- Parameters:
channel- data channelmessage- message
-
onWebRTCDataChannelBinaryMessage
Invoked when a binary message arrives on a channel. Each call carries one whole message. The array belongs to this call: to keep it beyond the call, copy it.- Parameters:
channel- data channelmessage- message
-
onWebRTCDataChannelClose
Invoked exactly once when a channel closes, whether the client closed it, a module closed it viaIWebRTCDataChannel.close(), or the connection was torn down.- Parameters:
channel- data channel
-