From 3f569b252a5b9df37f43f20113b49f771ad8c4db Mon Sep 17 00:00:00 2001 From: Marks Polakovs Date: Mon, 13 Apr 2020 15:05:08 +0200 Subject: [PATCH] fix that dumb shit --- src/broadcast/rtc_streamer.ts | 10 ++++++---- src/broadcast/state.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/broadcast/rtc_streamer.ts b/src/broadcast/rtc_streamer.ts index 7ab4cb4..dd05691 100644 --- a/src/broadcast/rtc_streamer.ts +++ b/src/broadcast/rtc_streamer.ts @@ -9,7 +9,7 @@ import { ConnectionStateListener, ConnectionStateEnum } from "./streamer"; -import store from "../store"; +import { Dispatch } from "redux"; type StreamerState = "HELLO" | "OFFER" | "ANSWER" | "CONNECTED"; @@ -19,13 +19,15 @@ export class WebRTCStreamer extends Streamer { ws: WebSocket | undefined; state: StreamerState = "HELLO"; isActive = false; + dispatch: Dispatch; newsInTimeout?: number; newsOutTimeout?: number; - constructor(stream: MediaStream) { + constructor(stream: MediaStream, dispatch: Dispatch) { super(); this.stream = stream; + this.dispatch = dispatch; } async start(): Promise { @@ -186,12 +188,12 @@ export class WebRTCStreamer extends Streamer { case "ACTIVATED": this.isActive = true; this.onStateChange("LIVE"); - store.dispatch(BroadcastState.setTracklisting(true)); + this.dispatch(BroadcastState.setTracklisting(true)); break; case "DEACTIVATED": this.isActive = false; this.onStateChange(this.mapStateToConnectionState()); - store.dispatch(BroadcastState.setTracklisting(false)); + this.dispatch(BroadcastState.setTracklisting(false)); break; case "DIED": // oo-er diff --git a/src/broadcast/state.ts b/src/broadcast/state.ts index 89df269..3d3e0df 100644 --- a/src/broadcast/state.ts +++ b/src/broadcast/state.ts @@ -242,7 +242,7 @@ export function sendTracklistStart(trackid: number): Promise { export const startStreaming = (): AppThunk => async (dispatch, getState) => { console.log("starting streamer."); - streamer = new WebRTCStreamer(MixerState.destination.stream); + streamer = new WebRTCStreamer(MixerState.destination.stream, dispatch); streamer.addConnectionStateListener(state => { dispatch(broadcastState.actions.setConnectionState(state)); if (state === "CONNECTION_LOST") {