Пример #1
0
        void OpenRemotingForm(string identity)
        {
            _syncRemotingCaptureActivity.Reset();

            if (!_view.IsRoomActivated(identity, GenericEnums.RoomType.Remoting))
            {
                Thread t = new Thread(delegate()
                {
                    try
                    {
                        //IntPtr handle = IntPtr.Zero;
                        FormRemotingRoom remotingRoom = new FormRemotingRoom(identity);
                        _view.RoomManager.AddRoom(identity, remotingRoom);
                        remotingRoom.BindCommandHandlers(SystemConfiguration.Instance.RemotingCommand);
                        // initialize new remoting  form

                        Contact contact = (Contact)_model.GetContact(identity);
                        // get friendly name from contacts list
                        if (contact != null)
                        {
                            _view.RoomManager.SetPartnerName(identity, GenericEnums.RoomType.Remoting, contact.FriendlyName);
                        }
                        // I am going to send my captures by using the below client

                        // create session
                        Session clientSession = new ClientSession(identity, GenericEnums.RoomType.Remoting);
                        _model.SessionManager.AddSession(clientSession, GenericEnums.RoomType.Remoting);

                        PeerStates peers = _model.SessionManager.GetPeerStatus(identity);
                        peers.RemotingSessionState = GenericEnums.SessionState.Opened;

                        // finally, show the video  form where we'll see the webcam captures
                        _view.RoomManager.ShowRoom(identity, GenericEnums.RoomType.Remoting);
                    }
                    catch (Exception ex)
                    {
                        Tools.Instance.Logger.LogError(ex.ToString());
                    }
                }
                );
                t.IsBackground = true;
                t.SetApartmentState(ApartmentState.STA);
                t.Start();

                Thread.Sleep(500);
                _syncRemotingCaptureActivity.Set();

            }
        }
Пример #2
0
        /// <summary>
        /// method used to initiate video conference with specific partner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void StartVideo(object sender, EventArgs args)
        {
            try
            {
                RoomActionEventArgs e = (RoomActionEventArgs)args;
                lock (_syncVideoStartStop)
                {
                    // conference start permission logic
                    bool hasPermission = true;
                    if (sender.GetType().IsEquivalentTo(typeof(UIControls.ActionsControl)))
                    {
                        hasPermission = _model.ClientController.ConferencePermission(e.Identity,
                            ((Identity)_model.Identity).MyIdentity, e.RoomType);
                    }
                    if (hasPermission)
                    {
                        // create client session
                        Session clientSession = new ClientSession(e.Identity, e.RoomType);
                        // save the proxy to which we are sending the webcam captures
                        _model.SessionManager.AddSession(clientSession, GenericEnums.RoomType.Video);

                        // open new Video form to receive the captures
                        OpenVideoForm(e.Identity);

                        // initialize the webcamCapture form
                        // this form will be used to capture the images and send them to all Server Sessions _presenter.StopPresentation();
                        _view.ShowMyWebcamForm(true);

                        // todo: put the audio back
                        Thread.Sleep(1000);
                        this.StartAudio(this, new RoomActionEventArgs()
                        {
                            Identity = e.Identity,
                            RoomType = GenericEnums.RoomType.Audio,
                            SignalType = GenericEnums.SignalType.Start
                        });
                    }
                    else
                    {
                        _view.SetMessageText("Video conference permission denied");
                    }
                }
            }
            catch (Exception ex)
            {
                Tools.Instance.Logger.LogError(ex.ToString());
            }
        }
Пример #3
0
        /// <summary>
        /// method used to initiate remoting conference with specific partner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void StartRemoting(object sender, EventArgs args)
        {
            try
            {
                RoomActionEventArgs e = (RoomActionEventArgs)args;
                lock (_syncRemotingStartStop)
                {
                    _syncRemotingCaptureActivity.Reset();

                    // conference start permission logic
                    bool hasPermission = true;
                    if (!sender.GetType().IsEquivalentTo(typeof(MViewerServer)))
                    {
                        hasPermission = _model.ClientController.ConferencePermission(e.Identity,
                            ((Identity)_model.Identity).MyIdentity, e.RoomType);
                    }
                    if (hasPermission)
                    {
                        // I am going to send my captures by using the below client
                        _model.ClientController.AddClient(e.Identity);
                        //_model.ClientController.StartClient(e.Identity);

                        // create client session
                        ClientSession clientSession = new ClientSession(e.Identity, e.RoomType);
                        // save the proxy to which we are sending the remoting captures
                        _model.SessionManager.AddSession(clientSession, GenericEnums.RoomType.Remoting);

                        // initialize the remoting tool and start it's timer
                        PresenterManager.Instance(SystemConfiguration.Instance.PresenterSettings).StartRemotingPresentation();
                        clientSession.Peers.RemotingSessionState = GenericEnums.SessionState.Opened;
                        _syncRemotingCaptureActivity.Set();
                    }
                    else
                    {
                        _view.SetMessageText("Remoting conference permission denied");
                    }
                }
            }
            catch (Exception ex)
            {
                Tools.Instance.Logger.LogError(ex.ToString());
            }
        }
Пример #4
0
        void OpenAudioForm(string identity)
        {
            if (!_view.IsRoomActivated(identity, GenericEnums.RoomType.Audio))
            {
                _syncAudioConferenceStatus.Reset();

                Thread t = new Thread(delegate()
                {
                    
                    try
                    {
                        Session clientSession = new ClientSession(identity, GenericEnums.RoomType.Audio);
                        _model.SessionManager.AddSession(clientSession, GenericEnums.RoomType.Audio);

                        //IntPtr handle = IntPtr.Zero;
                        FormAudioRoom audioRoom = new FormAudioRoom(identity, this.PlayAudioCapture);
                        _view.RoomManager.AddRoom(identity, audioRoom);
                        // initialize new Audio  form

                        PeerStates peers = _model.SessionManager.GetPeerStatus(identity);
                        peers.AudioSessionState = GenericEnums.SessionState.Opened;

                        audioRoom.ToggleAudioStatus();

                        ContactBase contact = _model.GetContact(identity);
                        // get friendly name from contacts list
                        _view.RoomManager.SetPartnerName(identity, GenericEnums.RoomType.Audio, ((Contact)contact).FriendlyName);
                        // finally, show the Audio  form where we'll see the webcam captures
                        _view.RoomManager.ShowRoom(identity, GenericEnums.RoomType.Audio);
                    }
                    catch (Exception ex)
                    {
                        Tools.Instance.Logger.LogError(ex.ToString());
                    }
                    
                }
                );
                t.IsBackground = true;
                t.SetApartmentState(ApartmentState.STA);
                t.Start();

                Thread.Sleep(500);
                _syncAudioConferenceStatus.Set();
            }
        }