nitanmarcel / tl_radio

Telegram UserBot to play and stream audio to telegram group chat using YoutubeDl and TgCalls.
GNU General Public License v3.0
16 stars 2 forks source link

Using is_connected args in on_network_changed #5

Open MarshalX opened 3 years ago

MarshalX commented 3 years ago

https://github.com/nitanmarcel/tl_radio/blob/45ec4de2e47cab502b669cf6d5d3fa1e734c0830/tl_radio/__main__.py#L178

Why are you sending request to the server? 🤔

@group_call.on_network_status_changed
    async def _reconnect(_, is_connected: bool):
        if not is_connected:
            await group_call.reconnect()

Doesnt it work for you?

MarshalX commented 3 years ago

Or you would like to have option to leave the voice chat? ;d

MarshalX commented 3 years ago

Doesn't the reconnection happen by itself in this case? Why is this code needed?

nitanmarcel commented 3 years ago

https://github.com/nitanmarcel/tl_radio/blob/45ec4de2e47cab502b669cf6d5d3fa1e734c0830/tl_radio/__main__.py#L178

Why are you sending request to the server? 🤔

@group_call.on_network_status_changed
    async def _reconnect(_, is_connected: bool):
        if not is_connected:
            await group_call.reconnect()

Doesnt it work for you?

There's

Or you would like to have option to leave the voice chat? ;d

I don't think I've found a documentation reffing to when and what happens on network status change.

The reconnect call is there just in case the bot disconnects from the voice chat. I haven't really tested the event honestly and if reconnecting is required.

nitanmarcel commented 3 years ago

Doesn't the reconnection happen by itself in this case? Why is this code needed?

The only thing I've noticed is that on_network_status_changed is triggered as soon as I start playing something and calling reconnect would stop the stream. I just used is_connected to call reconnect just when and if it's needed.

MarshalX commented 3 years ago

Doesn't the reconnection happen by itself in this case? Why is this code needed?

The only thing I've noticed is that on_network_status_changed is triggered as soon as I start playing something and calling reconnect would stop the stream. I just used is_connected to call reconnect just when and if it's needed.

it is triggered when webrtc successfully connected to the media servers. its means that you are connected to voice chat with 99% precision and ready to start playing/recording

nitanmarcel commented 3 years ago

Doesn't the reconnection happen by itself in this case? Why is this code needed?

The only thing I've noticed is that on_network_status_changed is triggered as soon as I start playing something and calling reconnect would stop the stream. I just used is_connected to call reconnect just when and if it's needed.

it is triggered when webrtc successfully connected to the media servers. its means that you are connected to voice chat with 99% precision and ready to start playing/recording

Oh, then I got misleaded by it's name. It made me think on something related to the current network status (temporary downtime in the internet connectivity).

nitanmarcel commented 3 years ago

Ok. I'm removing it in the next patch since I don't needed. And I'll probably experiment with actual network behaviors like random disconnects and reconnects in the 1.0.0 release 🤔

Unless the library handles that automatically @MarshalX ?