private void OnConversationActionAvailabilityChanged(object sender, ConversationActionAvailabilityEventArgs e) { //posts the execution into the UI thread RunAtUI (() => { //each action is mapped to a button in the UI switch (e.Action) { case ConversationAction.AddParticipant: IsCanAddParticipant = e.IsAvailable; break; case ConversationAction.RemoveParticipant: ParticipantCollection.UpdateCanRemoveParticipant(Conversation.CanInvoke(ConversationAction.RemoveParticipant)); _log.Debug("OnConversationActionAvailabilityChanged CanRemove:{0}" , Conversation.CanInvoke(ConversationAction.RemoveParticipant)); break; } _log.Debug("OnConversationActionAvailabilityChanged Send:{2} Action: {0} IsAvailable:{1} " , e.Action.ToString() , e.IsAvailable , sender); } ); }
private void SetParticipantVideoWindow(VideoChannel channel, VideoWindow window) { var model = ParticipantCollection.GetItem(channel); if (model != null && model != LocalParticipantVideoModel) { model.View = window; RemoteConnectParticipantVideoModel = model; } }
/// <summary> ///Decline another participants request to control locally owned and shared resource. ///The Decline button is enabled when the _sharingModality_ActionAvailabilityChanged event handler is ///called with the event argument that specifies the ModalityAction.DeclineSharingControlRequest action is available. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Decline() { //_selectedContact is set to the Contact object of the participant who requested control of the resource. //see the _sharingModality_ControlRequestReceived method in the application sharing modality event handlers region. ApplicationSharingModality sharingModality = ParticipantCollection.GetItem(_resourceControllingContact.Uri).ApplicationSharingModality; if (sharingModality != null && sharingModality.CanInvoke(ModalityAction.DeclineSharingControlRequest)) { sharingModality.BeginDeclineControlRequest((ar) => { sharingModality.EndDeclineControlRequest(ar); }, null); } }
/// <summary> ///Accept another participants request to control locally owned and shared resource. ///The Accept button is enabled when the _sharingModality_ActionAvailabilityChanged event handler is called ///with the event argument that specifies the ModalityAction.AcceptSharingControlRequest action is available. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Accept() { //_selectedContact is set to the Contact object of the participant who requested control of the resource. //see the _sharingModality_ControlRequestReceived method in the application sharing modality event handlers region. ApplicationSharingModality sharingModality = ParticipantCollection.GetItem(_resourceControllingContact.Uri).ApplicationSharingModality; //If the requesting participant application sharing modality is available and the AcceptSharingControlRequest action can be invoked if (sharingModality != null && sharingModality.CanInvoke(ModalityAction.AcceptSharingControlRequest)) { //Accept sharing control request. sharingModality.BeginAcceptControlRequest((ar) => { sharingModality.EndAcceptControlRequest(ar); }, null); } }
private void OnConversationParticipantRemoved(object sender, ParticipantCollectionChangedEventArgs e) { RunAtUI (() => { var removePart = ParticipantCollection.Remove(e.Participant.Contact.Uri); InvokePartConversationParticipantRemoved(removePart); _log.Debug("OnConversationParticipantRemoved uri:{0}", removePart.Participant.Contact.Uri); } ); }
private void OnConversationParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e) { RunAtUI (() => { var newPart = e.Participant; var newModel = CreateAndInitParticipant(newPart); ParticipantCollection.AddItem(newModel); _log.Debug("OnConversationParticipantAdded uri:{0}", newPart.Contact.Uri); InvokePartConversationParticipantAdded(newModel); } ); }
private void OnParticipantVideoChannelStateChanged(object sender, ChannelStateChangedEventArgs e) { //posts the execution into the UI thread RunAtUI(() => { _log.Debug("OnParticipantVideoChannelStateChanged OldState:{0} NewState:{1} Channel:{2} ChannelCode:{3}" , e.OldState.ToString() , e.NewState.ToString() , sender.ToString() , sender.GetHashCode() ); var channel = sender as VideoChannel; //if the outgoing video is now active, show the video (which is only available in UI Suppression Mode) if ((e.NewState == ChannelState.Send || e.NewState == ChannelState.SendReceive) && _videoChannel.CaptureVideoWindow != null) { ParticipantCollection.UpdateVideoWindow(channel, _videoChannel.CaptureVideoWindow, true); //SetParticipantVideoWindow(channel, _videoChannel.CaptureVideoWindow); } if (e.NewState == ChannelState.Receive && _videoChannel.RenderVideoWindow != null) { if (RemoteConnectParticipantVideoModel != null) { RemoteConnectParticipantVideoModel.View = null; } RemoteConnectParticipantVideoModel = null; } //if the incoming video is now active, show the video (which is only available in UI Suppression Mode) if ( e.NewState == ChannelState.SendReceive && _videoChannel.RenderVideoWindow != null) { ParticipantCollection.UpdateVideoWindow(channel, _videoChannel.RenderVideoWindow, false); ShowVideoPartView?.Invoke(); SetParticipantVideoWindow(channel, _videoChannel.RenderVideoWindow); } }); }
public void HandleAdded() { ParticipantCollection = ParticipantCollection.Instance; ParticipantCollection.Clear(); Conversation.ParticipantAdded += OnConversationParticipantAdded; Conversation.ParticipantRemoved += OnConversationParticipantRemoved; Conversation.StateChanged += OnConversationStateChanged; //subscribes to the conversation action availability events (for the ability to add/remove participants) Conversation.ActionAvailabilityChanged += OnConversationActionAvailabilityChanged; Conversation.PropertyChanged += OnConversationPropertyChanged; InitPart(); InvokePartHandleAdded(); AddParticipant(); }
/// <summary> ///Revoke control of a remotely controlled resource and locally owned shared resource. ///The Revoke button is enabled when the _sharingModality_ActionAvailabilityChanged event handler is called ///with the event argument that specifies the ModalityAction.RevokeSharingControl action is available. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Revoke() { if (_resourceControllingContact == null) { return; } ApplicationSharingModality sharingModality = ParticipantCollection.GetItem(_resourceControllingContact.Uri).ApplicationSharingModality; if (sharingModality != null && sharingModality.CanInvoke(ModalityAction.RevokeSharingControl)) { sharingModality.BeginRevokeControl((ar) => { try { sharingModality.EndRevokeControl(ar); } catch (OperationException oe) { _log.ErrorException("Operation exception ", oe); } } , null); } }
/// <summary> ///Grant another participant control of a locally owned and shared resource. ///The Grant button is enabled when the _sharingModality_ActionAvailabilityChanged event handler is ///called with the event argument that specifies the ModalityAction.GrantSharingControl action is available. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Grant() { //Get the sharing modality of the participant which the local user has selected to control the locally owned resource. try { ApplicationSharingModality sharingModality = (ApplicationSharingModality)ParticipantCollection.GetItem("TODO").ApplicationSharingModality; //If the application sharing modality is available and the resource can still be granted then grant //control of the resource. if (sharingModality != null && sharingModality.CanInvoke(ModalityAction.GrantSharingControl)) { sharingModality.BeginGrantControl((ar) => { sharingModality.EndGrantControl(ar); } , null); } } catch (KeyNotFoundException keyExp) { _log.ErrorException("Chosen participant does not have an application sharing modality.", keyExp); } catch (NullReferenceException exp) { _log.ErrorException("Chosen participant does not have an application sharing modality.", exp); } }