Beispiel #1
0
        public async Task OnPageAppearingAsync(ConnectionParameters connectionParameters, Action reRender = null)
        {
            _connectionParameters = connectionParameters;
            _reRender             = reRender;
            _userName             = connectionParameters.UserName;
            _cameraStream         = await _mediaStreamService.GetCameraMediaStreamAsync();

            _displayStream = await _mediaStreamService.GetDisplayMediaStreamAync();

            _mediaManagerService.Add(new MediaParameters
            {
                Label        = connectionParameters.UserName,
                Stream       = _cameraStream,
                VideoMuted   = false,
                AudioMuted   = false,
                ShowControls = false
            });

            reRender?.Invoke();

            var connectionRequestParameters = new ConnectionRequestParameters
            {
                ConnectionParameters = connectionParameters,
                LocalStream          = _cameraStream,
            };

            Connect(connectionRequestParameters);
        }
Beispiel #2
0
        private void Connect(ConnectionRequestParameters connectionRequestParameters)
        {
            _connectionDisposer = _webRtcConnection.ConnectionRequest(connectionRequestParameters).Subscribe(
                onNext: (peerResponseParameters) =>
            {
                switch (peerResponseParameters.Code)
                {
                case PeerResponseCode.PeerJoined:
                    if (peerResponseParameters.MediaStream != null)
                    {
                        _runOnUiThreadService.Invoke(() =>
                        {
                            _mediaManagerService.Add(new MediaParameters
                            {
                                Label        = peerResponseParameters.PeerUserName,
                                Stream       = peerResponseParameters.MediaStream,
                                VideoMuted   = false,
                                AudioMuted   = false,
                                ShowControls = false
                            });
                        });

                        _reRender?.Invoke();
                    }
                    break;

                case PeerResponseCode.PeerLeft:
                    _runOnUiThreadService.Invoke(() =>
                    {
                        _mediaManagerService.Remove(peerResponseParameters.PeerUserName);
                    });
                    _reRender?.Invoke();
                    System.Diagnostics.Debug.WriteLine($"************* APP PeerLeft");
                    break;

                case PeerResponseCode.PeerError:
                    _runOnUiThreadService.Invoke(() =>
                    {
                        _mediaManagerService.Remove(peerResponseParameters.PeerUserName);
                    });
                    _reRender?.Invoke();
                    System.Diagnostics.Debug.WriteLine($"************* APP PeerError");
                    break;
                }
            },
                onError: (exception) =>
            {
                System.Diagnostics.Debug.WriteLine($"************* APP OnError:{exception.Message}");
            },
                onCompleted: () =>
            {
                System.Diagnostics.Debug.WriteLine($"************* APP OnCompleted");
            });
        }
Beispiel #3
0
        public Task OnPageAppearingAsync(ConnectionParameters connectionParameters, Action reRender = null)
        {
            _reRender = reRender;
            if (_reRender is not null)
            {
                AddOrRemoveReRenderNotification();
            }

            var connectionRequestParameters = new ConnectionRequestParameters
            {
                ConnectionParameters = connectionParameters,
                DataChannelName      = connectionParameters.RoomName
            };

            Connect(connectionRequestParameters);
            return(Task.CompletedTask);
        }