Esempio n. 1
0
        private async Task OnReshareScreen()
        {
            await ExamServices.SendEvent(_examId, 1, "The test taker's desktop capture was cancelled", null);

            _inReshare = true;
            await Modal.ErrorAsync(new ConfirmOptions()
            {
                Title   = "Your desktop capture is interrupted",
                Content =
                    "You could probably clicked the 'Stop sharing' button, click 'OK' to re-initialize your screen capture"
            });

            while (_inReshare)
            {
                var streamId = await _webRtcClient.ObtainDesktopStream();

                if (streamId is "screen:0:0" or "Screen 1")
                {
                    if (_localDesktopVideoLoaded)
                    {
                        await _webRtcClient.SetDesktopVideoElement("local-desktop");
                    }
                    await _webRtcClient.StartStreamingDesktop();

                    _inReshare = false;
                }
Esempio n. 2
0
        /// <summary>
        /// Sends a new message
        /// </summary>
        /// <param name="message"></param>
        private async Task OnSendMessage(string message)
        {
            var ret = await ExamServices.SendEvent(_examId, Consts.MessageTypeProctor, message, _currentChatTaker);

            if (ret != ErrorCodes.Success)
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Failed to send message",
                    Content = ErrorCodes.MessageMap[ret]
                });
            }
            else
            {
                // After message being sent successfully, add the message to the message list
                // of the corresponding user
                if (_currentChatTaker == null)
                {
                    _broadcastMessages.Add(new EventItem()
                    {
                        Message = message,
                        Receipt = _currentChatTaker,
                        Sender  = "Me",
                        Time    = DateTime.Now,
                        Type    = Consts.MessageTypeProctor
                    });
                }
                else
                {
                    if (!_takerMessages.ContainsKey(_currentChatTaker))
                    {
                        _takerMessages[_currentChatTaker] = new List <EventItem>();
                    }

                    _takerMessages[_currentChatTaker].Add(new EventItem()
                    {
                        Message = message,
                        Receipt = _currentChatTaker,
                        Sender  = "Me",
                        Time    = DateTime.Now,
                        Type    = Consts.MessageTypeProctor
                    });
                }
            }
        }