diff --git a/src/broadcast/rtc_streamer.ts b/src/broadcast/rtc_streamer.ts index c9ff002..f27455c 100644 --- a/src/broadcast/rtc_streamer.ts +++ b/src/broadcast/rtc_streamer.ts @@ -1,6 +1,8 @@ import SdpTransform from "sdp-transform"; import * as later from "later"; +import raygun from "raygun4js"; + import * as BroadcastState from "./state"; import { Streamer, ConnectionStateEnum } from "./streamer"; @@ -56,7 +58,10 @@ export class WebRTCStreamer extends Streamer { console.log("WS created"); } - async stop(): Promise { + async stop(reason?: string): Promise { + raygun("send", { + error: new Error("Connection stop due to " + reason) + }); if (this.ws) { this.ws.close(); this.ws = null as any; @@ -181,7 +186,7 @@ export class WebRTCStreamer extends Streamer { // oo-er // server thinks we've lost connection // kill it on our end and trigger a reconnect - await this.stop(); + await this.stop("server DIED"); await this.start(); this.unexpectedDeath = true; break; @@ -203,13 +208,16 @@ export class WebRTCStreamer extends Streamer { ...iceServers, ], }); - this.pc.oniceconnectionstatechange = (e) => { + this.pc.oniceconnectionstatechange = async (e) => { if (!this.pc) { throw new Error( "Received ICEConnectionStateChange but PC was null?????" ); } console.log("ICE Connection state change: " + this.pc.iceConnectionState); + if (this.pc.iceConnectionState === "failed") { + await this.stop("ICE failure"); + } this.onStateChange(this.mapStateToConnectionState()); }; this.stream.getAudioTracks().forEach((track) => this.pc!.addTrack(track)); diff --git a/src/broadcast/state.ts b/src/broadcast/state.ts index 78d2431..ed86b3c 100644 --- a/src/broadcast/state.ts +++ b/src/broadcast/state.ts @@ -144,7 +144,7 @@ export const registerForShow = (): AppThunk => async (dispatch, getState) => { }) ); if (streamer) { - await streamer.stop(); + await streamer.stop("ApiException " + e.message); } } else { // let raygun handle it @@ -322,7 +322,7 @@ export const goOnAir = (): AppThunk => async (dispatch, getState) => { export const stopStreaming = (): AppThunk => async (dispatch) => { if (streamer) { - await streamer.stop(); + await streamer.stop("stopStreaming call"); streamer = null; } else { console.warn("disconnect called with no streamer!"); diff --git a/src/mixer/audio.ts b/src/mixer/audio.ts index 52f4073..a9567db 100644 --- a/src/mixer/audio.ts +++ b/src/mixer/audio.ts @@ -306,3 +306,4 @@ export class AudioEngine extends ((EngineEmitter as unknown) as { } export const audioEngine = new AudioEngine(); +(window as any).AE = audioEngine;