Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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("");
        }
Exemplo n.º 4
0
        private void HostTabEnterStartConnection()
        {
            RDPSession x = new RDPSession();

            x.OnAttendeeConnected += Incoming;
            x.Open();
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 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";
     }
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 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();
 }
Exemplo n.º 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);
        }
Exemplo n.º 13
0
 public static void Disconnect(RDPSession session)
 {
     try
     {
         session.Close();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 14
0
 public void createSession()  //made it non-static
 {
     lock (_lock)
     {
         if (null == currentSession)
         {
             currentSession = new RDPSession();
         }
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 17
0
 public static void Connect(RDPSession session)
 {
     try
     {
         session.OnAttendeeConnected += Incoming;
         session.Open();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 19
0
        private void Disconnect(RDPSession session)
        {
            session.Close();

            AxEventHandler <RemoteServerDisconnectEventArgs> handler = this.Disconnected;

            if (handler != null)
            {
                handler(new  RemoteServerDisconnectEventArgs(session));
            }
        }
Exemplo n.º 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
            });
        }
Exemplo n.º 21
0
        private void Connect(RDPSession session)
        {
            session.OnAttendeeConnected += Incoming;
            session.Open();

            AxEventHandler <RemoteServerConnectedEventArgs> handler = this.Connected;

            if (handler != null)
            {
                handler(new RemoteServerConnectedEventArgs(session));
            }
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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;
        }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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>
 }
Exemplo n.º 31
0
 private void button3_Click(object sender, EventArgs e)
 {
     x.Close();
     x = null;
 }