fix that dumb shit

This commit is contained in:
Marks Polakovs 2020-04-13 15:05:08 +02:00
parent 9da85215bb
commit 3f569b252a
2 changed files with 7 additions and 5 deletions

View file

@ -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<any>;
newsInTimeout?: number;
newsOutTimeout?: number;
constructor(stream: MediaStream) {
constructor(stream: MediaStream, dispatch: Dispatch<any>) {
super();
this.stream = stream;
this.dispatch = dispatch;
}
async start(): Promise<void> {
@ -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

View file

@ -242,7 +242,7 @@ export function sendTracklistStart(trackid: number): Promise<TrackListItem> {
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") {