keroserene / go-webrtc

WebRTC for Go
Other
455 stars 76 forks source link

backpressure and webrtc.DataChannel.OnMessage #45

Open amitu opened 8 years ago

amitu commented 8 years ago

How long should a handler attached to webrtc.DataChannel.OnMessage be allowed to take?

If I understand correctly, data channel buffer is drained after OnMessage is returned, so if I am reading from data channel and writing to a slow io.Writer(), I would prefer to block on io.Writer() from my OnMessage handler, but is it advisable for OnMessage to block?

Would it affect other data channels if we have more than one?

amitu commented 8 years ago

Another question: if I am in the callback, say OnMessage, can I call methods on dc before I return from it? Eg read the dc.ReadyState(), or call dc.Send() on it?