Example #1
0
        protected override async void OnOpen()
        {
            base.OnOpen();

            logger.LogDebug($"Web socket client connection from {Context.UserEndPoint}.");

            _pc = await CreatePeerConnection().ConfigureAwait(false);

            _pc.onicecandidate += (iceCandidate) =>
            {
                if (_pc.signalingState == RTCSignalingState.have_remote_offer)
                {
                    Context.WebSocket.Send(iceCandidate.toJSON());
                }
            };

            if (base.Context.QueryString["role"] != "offer")
            {
                var offerSdp = _pc.createOffer(OfferOptions);
                await _pc.setLocalDescription(offerSdp).ConfigureAwait(false);

                logger.LogDebug($"Sending SDP offer to client {Context.UserEndPoint}.");
                logger.LogDebug(offerSdp.sdp);

                Context.WebSocket.Send(offerSdp.toJSON());
            }
        }
        protected override async void OnOpen()
        {
            base.OnOpen();

            logger.LogDebug($"Web socket client connection from {Context.UserEndPoint}.");

            _pc = CreatePeerConnection();

            var offerSdp = _pc.createOffer(null);
            await _pc.setLocalDescription(offerSdp);

            _pc.onicecandidate += (iceCandidate) =>
            {
                if (_pc.signalingState == RTCSignalingState.have_remote_offer)
                {
                    Context.WebSocket.Send(iceCandidate.toJSON());
                }
            };

            logger.LogDebug($"Sending SDP offer to client {Context.UserEndPoint}.");
            logger.LogDebug(offerSdp.sdp);

            Context.WebSocket.Send(JsonConvert.SerializeObject(offerSdp,
                                                               new Newtonsoft.Json.Converters.StringEnumConverter()));
        }
        /// <summary>
        /// Creates a new WebRTC peer connection and send an SDP offer to the REST server.
        /// </summary>
        private async Task SendOffer(HttpClient httpClient)
        {
            logger.LogDebug("webrtc-rest sending initial SDP offer to server.");

            var offerSdp = _pc.createOffer(OfferOptions);

            await _pc.setLocalDescription(offerSdp).ConfigureAwait(false);

            await SendToSignalingServer(httpClient, offerSdp.toJSON(), WebRTCSignalTypesEnum.sdp).ConfigureAwait(false);
        }
Example #4
0
        /// <summary>
        /// Creates a new WebRTC peer connection and send an SDP offer to the node DSS server.
        /// </summary>
        private async Task SendOffer(HttpClient httpClient)
        {
            logger.LogDebug("node-dss sending initial SDP offer to server.");

            var offerSdp = _pc.createOffer(null);

            await _pc.setLocalDescription(offerSdp);

            await SendToNSS(httpClient, offerSdp.toJSON());
        }