public void SendLocalIceCandidate(IceCandidate _candidate) { executor.Execute(async() => { var json = SignalingMessage.CreateJson(_candidate); if (isInitiator) { if (App.HubConnection.State != HubConnectionState.Connected)//(State != ConnectionState.Connected) { ReportError("Sending ICE candidate in non connected state."); return; } //SendPostMessage(MessageType.Message, _messageUrl, json); //TODO: SignalR Send LocalIceCandidate as Initiator var isIceSent = await App.HubConnection.InvokeAsync <string>("SendLocalIceCandidate", App.HubConnection.ConnectionId, json); logger.Info(TAG, $"{isIceSent}"); } else { //_wsClient.Send(json); //TODO: SignalR Send LocalIceCandidate as Participant var isIceSent = await App.HubConnection.InvokeAsync <string>("SendLocalIceCandidate", App.HubConnection.ConnectionId, json); logger.Info(TAG, $"{isIceSent}"); } }); }
public void SendOfferSdp(SessionDescription _sessionDescriotion) { executor.Execute(async() => { if (App.HubConnection.State != HubConnectionState.Connected)//(State != ConnectionState.Connected) { ReportError("Sending offer SDP in non connected state."); return; } var json = SignalingMessage.CreateJson(_sessionDescriotion); //SendPostMessage(MessageType.Message, messageUrl, json); //TODO : SignalR SDPOffer Method var isOfferSent = await App.HubConnection.InvokeAsync <string>("SendOfferMessage", json); //TODO : Here, the you call a method in the SignalR Hub passing in a List of clients you want to call. if (roomConnectionParameters.IsLoopback) { // In loopback mode rename this offer to answer and route it back. var sdpAnswer = new SessionDescription(SdpType.Answer, _sessionDescriotion.Sdp); signalingEvents.OnRemoteDescription(sdpAnswer); } }); }
public void OnWebSocketMessage(string _message) { // Check HubConnection is Registered Connected if (App.HubConnection.State != HubConnectionState.Connected) { logger.Error(TAG, $"The SignalR HubConnection is in a Non-Connected State"); return; } var _signalingMessage = SignalingMessage.MessageFromJSONString(_message); switch (_signalingMessage.Type) { case SignalingMessageType.Candidate: var candidate = (ICECandidateMessage)_signalingMessage; signalingEvents.OnRemoteIceCandidate(candidate.Candidate); break; case SignalingMessageType.CandidateRemoval: var candidates = (ICECandidateRemovalMessage)_signalingMessage; signalingEvents.OnRemoteIceCandidatesRemoved(candidates.Candidates); break; case SignalingMessageType.Offer: if (!isInitiator) { var sdp = (SessionDescriptionMessage)_signalingMessage; signalingEvents.OnRemoteDescription(sdp.Description); } else { ReportError($"Received offer for call receiver : {_message}"); } break; case SignalingMessageType.Answer: if (isInitiator) { var sdp = (SessionDescriptionMessage)_signalingMessage; signalingEvents.OnRemoteDescription(sdp.Description); } else { ReportError($"Received answer for call initiator: {_message}"); } break; case SignalingMessageType.Bye: signalingEvents.OnChannelClose(); break; default: throw new ArgumentOutOfRangeException(); } }
public static SignalingMessage MessageFromJSONString(string json) { var values = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); SignalingMessage message = new SignalingMessage(); if (values.ContainsKey("type")) { var type = values["type"] ?? ""; switch (type) { case CandidateType: int.TryParse(values["label"], out int label); var candidate = new IceCandidate(values["candidate"], values["id"], label); message = new ICECandidateMessage(candidate); break; case CandidateRemovalType: break; case OfferType: var description = new SessionDescription(SdpType.Offer, values["sdp"]); message = new SessionDescriptionMessage(description); break; case AnswerType: description = new SessionDescription(SdpType.Answer, values["sdp"]); message = new SessionDescriptionMessage(description); break; case PrAnswerType: description = new SessionDescription(SdpType.PrAnswer, values["sdp"]); message = new SessionDescriptionMessage(description); break; case ByeType: message = new ByeMessage(); break; default: System.Diagnostics.Debug.WriteLine($"ARDSignalingMessage unexpected type: {type}"); break; } } else { System.Diagnostics.Debug.WriteLine($"ARDSignalingMessage invalid json: {json}"); } return(message); }
public void SendAnswerSdp(SessionDescription _sessionDescription) { executor.Execute(async() => { if (roomConnectionParameters.IsLoopback) { logger.Error(TAG, "Sending answer in loopback mode."); return; } var json = SignalingMessage.CreateJson(_sessionDescription); //_wsClient.Send(json); //TODO: SignalR SSPAnswer Method var isAnswerSent = await App.HubConnection.InvokeAsync <string>("SendAnswerMessage", json); }); }
public void SendLocalIceCandidateRemovals(IceCandidate[] _candidates) { executor.Execute(async() => { var json = SignalingMessage.CreateJson(_candidates); if (isInitiator) { if (App.HubConnection.State != HubConnectionState.Connected)//(State != ConnectionState.Connected) { ReportError("Sending ICE candidate removals in non connected state."); return; } //SendPostMessage(MessageType.Message, _messageUrl, json); //TODO: SignalR Send message to Remove Ice Candidates as Initiator var isIceRemoved = await App.HubConnection.InvokeAsync <string>("RemoveIceCandidates", json); logger.Info(TAG, $"{isIceRemoved}"); if (roomConnectionParameters.IsLoopback) { signalingEvents.OnRemoteIceCandidatesRemoved(_candidates); } } else { //_wsClient.Send(json); //TODO: SignalR Send message to Remove Ice Candidates as Participant var isIceRemoved = await App.HubConnection.InvokeAsync <string>("RemoveIceCandidates", json); logger.Info(TAG, $"{isIceRemoved}"); if (roomConnectionParameters.IsLoopback) { signalingEvents.OnRemoteIceCandidatesRemoved(_candidates); } } }); }