You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Zello Channels JS SDK for PTT a user may start and end a stream before getting a response from the start_stream event from either Session.startVoiceMessage() or direct calls to OutgoingMessage.start() in the case of autoStart: false. This sequences of events results in a less than desirable clean up task in the current implementation.
A work around using a callback for startVoiceMessage also does not appear to be a viable option.
constcallbacks=newWeakMap();constoutgoingMessage=session.startVoiceMessage((error,data)=>{// on error, no action needed. Clean up handled by// `Session.sendCommandWithCallback()` rejecting the promise// referenced by `OutgoingMessage.start()` and calling// `this.stopRecording()`.if(error===null){callbacks.delete(outgoingMessage);return;}constcallback=callbacks.get(outgoingMessage);callback(error,data);});try{awaitoutgoingMessage.stop();}catch(error){callbacks.set(outgoingMessage,(error,data)=>{// `OutgoingMessage.currentMessageId` is set after the resolution// of this callback, as such we can not make use of// `OutgoingMessage.stop()`.session.stopStream({stream_id: data.stream_id});// After callback `OutgoingMessage.start()` will then set// `currentMessageId` and call `OutgoingMessage.startRecording()`.// This is not desired as the call has been requested to stop.// An `Error` could be thrown to prevent this, ensuring recorder// is not started and left running, and sending data. However, this// leaves the `Session.sendCommandWithCallback()` Promise// unresolved.thrownewError();})}
An alternate method is to add a listener for the recorder or encoder, and placing clean up code there, which is still not ideal solution.
The text was updated successfully, but these errors were encountered:
When using Zello Channels JS SDK for PTT a user may start and end a stream before getting a response from the
start_stream
event from eitherSession.startVoiceMessage()
or direct calls toOutgoingMessage.start()
in the case ofautoStart: false
. This sequences of events results in a less than desirable clean up task in the current implementation.Consider the below snippet.
Due to the race condition with receiving the stream id, the clients socket traffic may look like so.
A work around using a callback for
startVoiceMessage
also does not appear to be a viable option.An alternate method is to add a listener for the recorder or encoder, and placing clean up code there, which is still not ideal solution.
The text was updated successfully, but these errors were encountered: