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);
                }
            });
        }
Exemple #2
0
        public void SendOfferSdp(SessionDescription sdp)
        {
            _executor.Execute(() =>
            {
                if (State != ConnectionState.Connected)
                {
                    ReportError("Sending offer SDP in non connected state.");
                    return;
                }

                var json = SignalingMessage.CreateJson(sdp);

                SendPostMessage(MessageType.Message, _messageUrl, json);

                if (_connectionParameters.IsLoopback)
                {
                    // In loopback mode rename this offer to answer and route it back.
                    var sdpAnswer = new SessionDescription(SdpType.Answer, sdp.Sdp);
                    _signalingEvents.OnRemoteDescription(sdpAnswer);
                }
            });
        }
        public void OnWebSocketMessage(string message)
        {
            if (_wsClient.State != WebSocketConnectionState.Registered)
            {
                _logger.Error(TAG, "Got WebSocket message in non registered state.");
                return;
            }

            var msg = SignalingMessage.FromJson(message);

            switch (msg.MessageType)
            {
            case SignalingMessageType.Unknown:
                _logger.Error(TAG, $"Got unknown message: {message}");
                break;

            case SignalingMessageType.Register:
            case SignalingMessageType.Offer:
            case SignalingMessageType.SendCandidate:
                _logger.Error(TAG, $"Got wrong message type: {msg.MessageType}");
                break;

            case SignalingMessageType.Registered:
                var registerMessage = (RegisteredMessage)msg;
                SignalingParametersReady(registerMessage);
                break;

            case SignalingMessageType.ReceivedAnswer:
                var answerMessage = (SessionDescriptionMessage)msg;
                _signalingEvents.OnRemoteDescription(answerMessage.Description);
                break;

            case SignalingMessageType.ReceiveCandidate:
                var candidateMessage = (IceCandidateMessage)msg;
                var iceCandidate     = candidateMessage.IceCandidate;
                _signalingEvents.OnRemoteIceCandidate(new IceCandidate(iceCandidate.Sdp, iceCandidate.SdpMid,
                                                                       iceCandidate.SdpMLineIndex));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }