Пример #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
        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
        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
        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
        /// <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
 public void createSession()  //made it non-static
 {
     lock (_lock)
     {
         if (null == currentSession)
         {
             currentSession = new RDPSession();
         }
     }
 }
Пример #15
0
 /// <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
 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
        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
        private void Disconnect(RDPSession session)
        {
            session.Close();

            AxEventHandler <RemoteServerDisconnectEventArgs> handler = this.Disconnected;

            if (handler != null)
            {
                handler(new  RemoteServerDisconnectEventArgs(session));
            }
        }
Пример #20
0
        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
        private void Connect(RDPSession session)
        {
            session.OnAttendeeConnected += Incoming;
            session.Open();

            AxEventHandler <RemoteServerConnectedEventArgs> handler = this.Connected;

            if (handler != null)
            {
                handler(new RemoteServerConnectedEventArgs(session));
            }
        }
Пример #22
0
 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
        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);
        }
 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
 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
 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
 private void button3_Click(object sender, EventArgs e)
 {
     x.Close();
     x = null;
 }