private async void ConnectToHubRoom() { try { State = ConnectionState.New; //TODO: Call SignalR Hub Connect To Room; This returns The relevant Room Parameters and potential errors if available. //await App.HubConnection.StartAsync(); var str = await App.HubConnection.InvokeAsync <string>("GetRoomParametersAsync", roomConnectionParameters.RoomId, roomConnectionParameters.IsInitator, "https://global.xirsys.net/_turn/DemoWebRTC"); var roomSObject = JObject.Parse(str); var roomParams = roomSObject.ToObject <RoomParameterResponse>(); var _roomSignalingParameters = new SignalingParameters { IsInitiator = roomParams.IsInitiator, ClientId = roomParams.ClientId, IceServers = roomParams.IceServers, IceCandidates = roomParams.IceCandidates, OfferSdp = roomParams.OfferSdp }; executor.Execute(() => { SignalingParametersReady(_roomSignalingParameters); }); } catch (Exception ex) { ReportError($"ERROR {ex.Message}"); return; } }
private void SignalingParametersReady(SignalingParameters _roomSignalingParameters) { logger.Debug(TAG, "Room connection completed."); if (roomConnectionParameters.IsLoopback && (!_roomSignalingParameters.IsInitiator || _roomSignalingParameters.OfferSdp != null)) { ReportError("Loopback room is busy."); return; } if (!roomConnectionParameters.IsLoopback && !_roomSignalingParameters.IsInitiator && _roomSignalingParameters.OfferSdp == null) { logger.Warning(TAG, "No offer SDP in room response."); } isInitiator = _roomSignalingParameters.IsInitiator; signalingEvents.OnChannelConnected(_roomSignalingParameters); }