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
Noticed that the callback onDisconnect is not being called when executing stopStreaming.
Is this intentional? Or an error?
Motivation
My users can only stream inside of a time based window. Meaning they will get disconnected when the time reaches the end time of that predefined time window. In order to accommodate this on mobile. When the end time is reached, the live stream will shut down and close the live stream page. Meaning i gotta know when the connection have been closed before i close the stream view.
Problem
In the stopStreaming method
The rtmpConnection.close() might go async at some point.
Meaning the event listeners will get removed before the connection is actually closed.
Or rtmpConnection.close() might not trigger the rtmpStatusHandler at all for some reason.
Solution
Have a private enum that contains the status that we want the live stream to be in.
Meaning in startStreaming, we set this variable to "streaming".
So if the connection fails, we know if the user wants the stream and we can retry the connection.
In stopStreamingwe set the enum to "stopped". When the rtmpStatusHandler reaches RTMPConnection.Code.connectClosed.rawValue we can first onDisconnect and afterwards check the enum, and then remove the event listeners.
Can make a pr. But want a go ahead first.
The text was updated successfully, but these errors were encountered:
You are right there should be a onDisconnect event when user calls stopStreaming. I have tried to comment the part that removes the event listeners but rtmpStatusHandler is not called. See shogo4405/HaishinKit.swift#671 (comment)
Unfortunately, the easiest solution I see is to trigger onDisconnect in the stopStreaming if the application is connected.
Summary
Noticed that the callback
onDisconnect
is not being called when executingstopStreaming
.Is this intentional? Or an error?
Motivation
My users can only stream inside of a time based window. Meaning they will get disconnected when the time reaches the end time of that predefined time window. In order to accommodate this on mobile. When the end time is reached, the live stream will shut down and close the live stream page. Meaning i gotta know when the connection have been closed before i close the stream view.
Problem
In the stopStreaming method
The
rtmpConnection.close()
might go async at some point.Meaning the event listeners will get removed before the connection is actually closed.
Or
rtmpConnection.close()
might not trigger thertmpStatusHandler
at all for some reason.Solution
Have a private enum that contains the status that we want the live stream to be in.
Meaning in startStreaming, we set this variable to "streaming".
So if the connection fails, we know if the user wants the stream and we can retry the connection.
In
stopStreaming
we set the enum to "stopped". When thertmpStatusHandler
reachesRTMPConnection.Code.connectClosed.rawValue
we can firstonDisconnect
and afterwards check the enum, and then remove the event listeners.Can make a pr. But want a go ahead first.
The text was updated successfully, but these errors were encountered: