コード例 #1
0
        public void destroy()
        {
            try {
                lock (this) {
                    if (null == currentSession)
                    {
                        return;
                    }

                    ReleaseEventHandlers();
                    currentSession.Close();
                    currentSession = null;
                    controlString  = null;

                    isSessionAlive = false;

                    countControlClient = 0;
                    countViewClient    = 0;
                    ReleaseEventHandlers();
                }
            } catch (Exception Ex) {
                // MessageBox.Show("Error Connecting", "Error connecting to remote desktop " + " Error:  " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Console.WriteLine("error disconnecting" + Ex);
                throw Ex;
            }
        }
コード例 #2
0
ファイル: Hub.cs プロジェクト: 700hours/Screen-Share
        private void Button_Begin_Click(object sender, EventArgs e)
        {
            if (Button_Begin.Text == "Initiate")
            {
                session = new RDPSession();

                session.OnAttendeeConnected += Incoming;
                session.Open();

                var info = new ConnectInfo();
                info.ShowDialog();

                IRDPSRAPIInvitation invitation = session.Invitations.CreateInvitation(auth, group, pass, 10);
                Text_Key.Text = invitation.ConnectionString;

                Buttons(Setting.Basic, true);
            }
            else if (Button_Begin.Text == "Begin")
            {
                var info = new Credentials();
                info.ShowDialog();

                Screen.key = Text_Key.Text;
                var screen = new Screen();
                screen.Start();
                screen.ShowDialog();

                Buttons(Setting.Basic, true);
            }
        }
コード例 #3
0
        /**
         * starts a new RDP session and a new invitation, and returns the corresponding invite string.
         * returns the empty string if the start failed.
         * */
        private String CreateNewTicklet()
        {
            try
            {
                StartRDPSession();
                String invite = connectionString == null?GetInviteString() : connectionString;

                Console.WriteLine("Ticklet Creation Succeeded!");
                return(invite);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Console.WriteLine("Ticklet Creation Failed :(");
                Console.WriteLine(e.Message);
                if (rdpSession != null)
                {
                    Action TickletFail = () => {
                        textBox1.Text        = "Ticklet was rejected, please try again";
                        submitButton.Enabled = true;
                    };
                    this.Invoke(TickletFail);
                    rdpSession.Close();
                    rdpSession = null;
                }
            }

            return("");
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: wj-wong/ArmShareX
        private void HostTabEnterStartConnection()
        {
            RDPSession x = new RDPSession();

            x.OnAttendeeConnected += Incoming;
            x.Open();
        }
コード例 #5
0
        private void StopButton_Click(object sender, EventArgs e)
        {
            StartButton.Enabled = true;
            StopButton.Enabled  = false;

            try
            {
                MessagesClass propTest = new MessagesClass();
                propTest.netShutdown();
                m_pRdpSession.Close();
                //LogTextBox.Text += "Presentation Stopped." + Environment.NewLine;
                LogTextBox.AppendText("Presentation Stopped." + Environment.NewLine);
                Marshal.ReleaseComObject(m_pRdpSession);
                m_pRdpSession = null;
            }
            catch (Exception ex)
            {
                //LogTextBox.Text += "Error occured while stopping presentation. Error: " + ex.ToString();
                LogTextBox.AppendText("Error occured while stopping presentation. Error: " + ex.ToString() + Environment.NewLine);

                StartButton.Enabled = false;
                StopButton.Enabled  = false;
                checkBox1.Enabled   = false;

                LogTextBox.AppendText("Please exit the program." + Environment.NewLine);
            }
        }
コード例 #6
0
ファイル: Client.cs プロジェクト: SvetPlanet/RemoteDesktop
        public void Dispose()
        {
            ConnectionString = string.Empty;
            Connected        = false;
            ListenOn         = false;
            try
            {
                if (RdpSession != null)
                {
                    foreach (IRDPSRAPIAttendee attendees in RdpSession.Attendees)
                    {
                        attendees.TerminateConnection();
                    }

                    RdpSession.Close();
                    RdpSession = null;
                }
            }
            catch { }
            try
            {
                TcpClient.GetStream().Close();
            }
            catch { }
            MessageBroker = null;
            TcpClient.Close();
            TcpClient       = null;
            Settings        = null;
            User            = null;
            AuthData        = null;
            MessageListener = null;
        }
コード例 #7
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            if (!ongoingSession)
            {
                try
                {
                    if (m_pRdpSession == null)
                    {
                        m_pRdpSession = new RDPSession();
                    }

                    m_pRdpSession.OnAttendeeConnected         += new _IRDPSessionEvents_OnAttendeeConnectedEventHandler(OnAttendeeConnected);
                    m_pRdpSession.OnAttendeeDisconnected      += new _IRDPSessionEvents_OnAttendeeDisconnectedEventHandler(OnAttendeeDisconnected);
                    m_pRdpSession.OnControlLevelChangeRequest += new _IRDPSessionEvents_OnControlLevelChangeRequestEventHandler(OnControlLevelChangeRequest);
                    var properties = m_pRdpSession.Properties;
                    properties["EnableClipboardRedirect"] = true;
                    SetSharingMode();

                    m_pRdpSession.Open();
                    IRDPSRAPIInvitation pInvitation = m_pRdpSession.Invitations.CreateInvitation("WinPresenter", "PresentationGroup", "", 5);
                    string invitationString         = pInvitation.ConnectionString;
                    WriteToFile(invitationString);
                    LogTextBox.Text += $"Presentation Started. {this.SharingModeComboBox.GetItemText(this.SharingModeComboBox.SelectedItem)} is being shared." + Environment.NewLine;
                    ongoingSession   = true;
                }
                catch (Exception ex)
                {
                    LogTextBox.Text += "Error occured while starting presentation. Error: " + ex.ToString() + Environment.NewLine;
                }
            }
        }
コード例 #8
0
 private void ButtonHost_Click(object sender, RoutedEventArgs e)
 {
     if (x == null)
     {
         x = new RDPSession();
         x.OnAttendeeConnected += Incoming;
         x.Open();
         IRDPSRAPIInvitation Invitation = x.Invitations.CreateInvitation("Trial", "MyGroup", "", 10);
         //ButtonHost.Visibility = Visibility.Hidden;
         //ButtonStopHost.Visibility = Visibility.Visible;
         if (trafficController.GetState() == State.OpenedGate)
         {
             messageSendTime = DateTime.Now;
             /// Wysyłanie konkretnej wiadomości do kontaktu, z którym mamy otwartego gate'a
             TextBoxMessage.Text = "Ekran udostępniony";
             trafficController.SMSSend(nr.ToString(), null, szyfr2 + Invitation.ConnectionString, "", "" + messageSendTime);
             messageSend = true;
         }
     }
     else
     {
         x.Close();
         x = null;
         TextBoxMessage.Text = "Udostępnianie przerwane";
     }
 }
コード例 #9
0
        private void btnStartCast_Click(object sender, EventArgs e)
        {
            var dlg = new CaptureScreen()
            {
                Owner = this
            };
            var result = dlg.ShowDialog();

            if (result == DialogResult.No)
            {
                return;
            }
            Rectangle rect = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

            if (result == DialogResult.Yes)
            {
                rect = dlg.SelectedRectangle;
            }

            try
            {
                btnStartCast.Enabled = false;

                _rdpSession = new RDPSession();

                _attendees.Clear();

                _rdpSession.OnAttendeeConnected         += RdpSessionOnOnAttendeeConnected;
                _rdpSession.OnAttendeeDisconnected      += RdpSessionOnOnAttendeeDisconnected;
                _rdpSession.OnControlLevelChangeRequest += RdpSessionOnOnControlLevelChangeRequest;

                //_rdpSession.SetDesktopSharedRect(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                _rdpSession.SetDesktopSharedRect(rect.X, rect.Y, rect.Right, rect.Bottom);

                _rdpSession.Open();


                IRDPSRAPIInvitation invitation = _rdpSession.Invitations.CreateInvitation("PalmaeTech", "CastGroup", "",
                                                                                          64);

                _hostCaster.StartCast(invitation.ConnectionString);

                btnStopCast.Enabled = true;
                notifyIcon1.Text    = "屏幕广播已启动";
                notifyIcon1.ShowBalloonTip(1000, "屏幕广播启动成功", "屏幕广播已启动,程序已最小化到右下角系统通知区域。", ToolTipIcon.Info);

                this.ShowInTaskbar = false;
                this.Hide();

                _isRunning = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                btnStartCast.Enabled = true;
                btnStopCast.Enabled  = false;
                _isRunning           = false;
            }
        }
コード例 #10
0
ファイル: RemoteServer.cs プロジェクト: m-atef/SharpView
        /// <summary>
        /// Create the specified password.
        /// </summary>
        /// <param name="password">Password.</param>
        public void Create(string password)
        {
            currentSession = new RDPSession();
            Connect(currentSession);
            var invitation = DesktopInvitation = getConnectionString(currentSession, Environment.UserDomainName, "SharpView", password, 5);

            ConnectionId = invitation.ConnectionString;
        }
コード例 #11
0
 public static void Connect(RDPSession session)
 {
     session.ApplicationFilter.Enabled       = false;
     session.OnSharedDesktopSettingsChanged += Session_OnSharedDesktopSettingsChanged;
     session.colordepth           = 8;
     session.OnChannelDataSent   += Session_OnChannelDataSent;
     session.OnAttendeeConnected += Incoming;
     session.Open();
 }
コード例 #12
0
        public static string getConnectionString(RDPSession session, String authString,
                                                 string group, string password, int clientLimit)
        {
            IRDPSRAPIInvitation invitation =
                session.Invitations.CreateInvitation
                    (authString, group, password, clientLimit);

            return(invitation.ConnectionString);
        }
コード例 #13
0
 public static void Disconnect(RDPSession session)
 {
     try
     {
         session.Close();
     }
     catch (Exception)
     {
     }
 }
コード例 #14
0
ファイル: SharePc.cs プロジェクト: foringH/RDP-Server-V2
 public void createSession()  //made it non-static
 {
     lock (_lock)
     {
         if (null == currentSession)
         {
             currentSession = new RDPSession();
         }
     }
 }
コード例 #15
0
ファイル: RdpSessionServer.cs プロジェクト: Heide172/dpR
 /// <summary>
 /// Constructor <see cref="RdpSessionServer"/>.
 /// </summary>
 public RdpSessionServer()
 {
     // Specifies the color depth of the session in bits per pixel (bpp). The color depth is always 32. If you specify any other value, the color depth is set to 32 bpp.
     // Windows Server 2008 R2: Possible values are 16 and 24.If you specify a value of 8, the color depth is set to 16 bpp.
     // Windows Server 2008 and Windows Vista: Possible values are 8, 16, and 24 bpp.
     _rdpSession = new RDPSession {
         colordepth = 8
     };
     _rdpSession.add_OnAttendeeConnected(OnAttendeeConnected);
 }
コード例 #16
0
ファイル: Form1.cs プロジェクト: foringH/RDP_Server-Client
 public static void Disconnect(RDPSession session)
 {
     try
     {
         session.Close();
     }
     catch (Exception Ex)
     {
         MessageBox.Show("Error Connecting", "Error connecting to remote desktop " + " Error:  " + Ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #17
0
 public static void Connect(RDPSession session)
 {
     try
     {
         session.OnAttendeeConnected += Incoming;
         session.Open();
     }
     catch (Exception)
     {
     }
 }
コード例 #18
0
ファイル: Remote.cs プロジェクト: Yanotek/Lizzard
        public string ConnectionString()
        {
            session = new RDPSession();
            session.Open();

            session.add_OnAttendeeConnected(OnAttendeeConnected);

            IRDPSRAPIInvitation invitation = session.Invitations.CreateInvitation(null, screenCommand.UserName, screenCommand.Password, 1);

            return(invitation.ConnectionString);
        }
コード例 #19
0
ファイル: RemoteServer.cs プロジェクト: m-atef/SharpView
        private void Disconnect(RDPSession session)
        {
            session.Close();

            AxEventHandler <RemoteServerDisconnectEventArgs> handler = this.Disconnected;

            if (handler != null)
            {
                handler(new  RemoteServerDisconnectEventArgs(session));
            }
        }
コード例 #20
0
ファイル: RemoteServer.cs プロジェクト: m-atef/SharpView
        private RemoteDesktopInvitation getConnectionString(RDPSession session, String authString,
                                                            string group, string password, int clientLimit)
        {
            IRDPSRAPIInvitation invitation =
                session.Invitations.CreateInvitation
                    (authString, group, password, clientLimit);

            return(new SharpViewCore.RemoteDesktopInvitation(invitation.ConnectionString, invitation.GroupName, invitation.Password)
            {
                AttendeeLimit = invitation.AttendeeLimit, Revoked = invitation.Revoked
            });
        }
コード例 #21
0
ファイル: RemoteServer.cs プロジェクト: m-atef/SharpView
        private void Connect(RDPSession session)
        {
            session.OnAttendeeConnected += Incoming;
            session.Open();

            AxEventHandler <RemoteServerConnectedEventArgs> handler = this.Connected;

            if (handler != null)
            {
                handler(new RemoteServerConnectedEventArgs(session));
            }
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: wj-wong/ArmShareX
 private void HostButton2_Click(object sender, EventArgs e)
 {
     if (counterDisconnector > 0)
     {
         MessageBox.Show("You have already Disconnected The Connection, Please Restart And Try Again");
     }
     else
     {
         counterDisconnector++;
         x.Close();
         x = null;
     }
 }
コード例 #23
0
ファイル: Client.cs プロジェクト: SvetPlanet/RemoteDesktop
        public Client(Settings settings, User user, AuthorizationData authData, ThreadMethod listening, bool firstRun)
        {
            this.Settings = settings;
            this.User     = user;
            this.AuthData = authData;
            if (firstRun)
            {
                RdpSession = new RDPSession();
            }
            ThreadStart threadDelegate = new ThreadStart(listening);

            MessageListener = new Thread(threadDelegate);
        }
コード例 #24
0
 public void CloseShare()
 {
     try
     {
         m_pRdpSession.Close();
         Marshal.ReleaseComObject(m_pRdpSession);
         m_pRdpSession = null;
     }
     catch (Exception ex)
     {
         //LogTextBox.Text += "Error occured while stopping presentation. Error: " + ex.ToString();
     }
 }
コード例 #25
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            FriendData friend = ClientInformation.GetFriend(Partner);

            if (friend.Status && !ClientInformation.AnswerWindows.ContainsKey(friend.Username) && !ClientInformation.CallingWindows.ContainsKey(friend.Username))
            {
                RDPSession rdpSession = new RDPSession();
                rdpSession.OnAttendeeConnected += Incoming;
                rdpSession.Open();

                IRDPSRAPIInvitation Invitation = rdpSession.Invitations.CreateInvitation(ClientInformation.Username, Partner, "", 1);
                ClientInformation.ScreenShareService.InitShareScreen(ClientInformation.Username, Partner, Invitation.ConnectionString);
            }
        }
コード例 #26
0
ファイル: Client.cs プロジェクト: SvetPlanet/RemoteDesktop
 public void CreateSession(bool fullDesktop, string chosenApp = "")
 {
     if (RdpSession == null)
     {
         RdpSession = new RDPSession();
     }
     RdpSession.OnControlLevelChangeRequest += ChangeControl;
     RdpSession.OnAttendeeConnected         += Incoming;
     RdpSession.Open();
     if (!fullDesktop)
     {
         RdpSession.ApplicationFilter.Enabled = true;
         SetAppForSharing(chosenApp);
     }
 }
コード例 #27
0
        public Service(RDPSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            // store the session
            this.session = session;

            // hook the session events
            session.OnAttendeeConnected         += OnAttendeeConnected;
            session.OnControlLevelChangeRequest += OnControlLevelChangeRequest;
            session.OnAttendeeDisconnected      += OnAttendeeDisconnected;
        }
コード例 #28
0
ファイル: WinSharer.cs プロジェクト: wangh1978/WinPresenter
 private void StopButton_Click(object sender, EventArgs e)
 {
     try
     {
         m_Timer.Start();
         m_pRdpSession.Close();
         LogTextBox.Text += "停止共享." + Environment.NewLine;
         Marshal.ReleaseComObject(m_pRdpSession);
         m_pRdpSession = null;
     }
     catch (Exception ex)
     {
         LogTextBox.Text += "停止共享出错. 错误: " + ex.ToString();
     }
 }
コード例 #29
0
 private void StopButton_Click(object sender, EventArgs e)
 {
     try
     {
         m_pRdpSession.Close();
         LogTextBox.Text += "Presentation Stopped." + Environment.NewLine;
         Marshal.ReleaseComObject(m_pRdpSession);
         m_pRdpSession  = null;
         ongoingSession = false;
     }
     catch (Exception ex)
     {
         LogTextBox.Text += "Error occured while stopping presentation. Error: " + ex.ToString();
     }
 }
コード例 #30
0
 public RdpTcpClient()
 {
     try
     {
         m_pRdpSession            = new RDPSession();
         m_pRdpSession.colordepth = 8;
         m_pRdpSession.SetDesktopSharedRect(0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
         m_pRdpSession.OnAttendeeConnected         += new _IRDPSessionEvents_OnAttendeeConnectedEventHandler(OnAttendeeConnected);
         m_pRdpSession.OnAttendeeDisconnected      += new _IRDPSessionEvents_OnAttendeeDisconnectedEventHandler(OnAttendeeDisconnected);
         m_pRdpSession.OnControlLevelChangeRequest += new _IRDPSessionEvents_OnControlLevelChangeRequestEventHandler(OnControlLevelChangeRequest);
         m_pRdpSession.Open();
         IRDPSRAPIInvitation invitation = m_pRdpSession.Invitations.CreateInvitation("baseAuth", "groupName", "", 2);
         m_rdpConnectionString = invitation.ConnectionString;
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(invitation.ConnectionString);
         XmlNodeList nlist = doc.SelectNodes("//L");
         if (nlist != null && nlist.Count > 0)
         {
             for (int i = 0; i < nlist.Count; i++)
             {
                 XmlAttribute attrhost = nlist[i].Attributes["N"];
                 if (attrhost != null)
                 {
                     if (attrhost.Value.IndexOf(":") > 0)
                     {
                         //ipv6
                     }
                     else if (attrhost.Value.IndexOf(".") > 0)
                     {
                         //ipv4
                         XmlAttribute attrport = nlist[i].Attributes["P"];
                         if (attrport != null)
                         {
                             int.TryParse(attrport.Value, out m_rdpport);
                             m_rdphost = attrhost.Value;
                             break;
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         Logger.Trace(e);
     }
     //<E><A KH="jebWL5nMyWOiBHyxcM08QPxhQ4E=" ID="baseAuth"/><C><T ID="1" SID="3344616568"><L P="5247" N="fe80::dc3d:7c76:b517:75fb%11"/><L P="5248" N="192.168.10.175"/></T></C></E>
 }
コード例 #31
0
ファイル: Form1.cs プロジェクト: twfahey1/Screen-Sharing
 private void button3_Click(object sender, EventArgs e)
 {
     x.Close();
     x = null;
 }