Skip to content

Station listeners counter#8

Open
foxy-eyed wants to merge 3 commits intoday-3from
feature/listeners-counter
Open

Station listeners counter#8
foxy-eyed wants to merge 3 commits intoday-3from
feature/listeners-counter

Conversation

@foxy-eyed
Copy link
Owner

@foxy-eyed foxy-eyed commented Aug 2, 2023

Добавить в плеер в режиме трансляции отображение числа активных слушателей. При этом каждую сущность плеера считаем уникальным слушателем (даже если этот один и тот же пользователь).

При включении станции в одном окне браузера, счётчик у транслирующего увеличивается на единицу. При закрытии окна — уменьшается на единицу.

BnrHeMlAFo

@foxy-eyed foxy-eyed marked this pull request as ready for review August 2, 2023 06:02
Copy link

@palkan palkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Про это PR уже всё сказали в чате))

counter = StationTracker.current_listeners(station)

Turbo::StreamsChannel.broadcast_update_to(
verified_stream_name_from_params,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А можно было тут просто передать station? А то сейчас какие внутренности вылезли наружу

after_unsubscribe :untrack_listener

def track_listener
StationTracker.track_listener(station)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы StationTracker повысил до модели (связанной с LiveStation) и присоединил к станции, чтобы получилось что-то вроде:

station.listeners_tracker.increment

Так сказать, ближе к земле к Rails Way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants