コード例 #1
0
ファイル: ScreenShare.cs プロジェクト: futtrup91/LabRun
        public void Start(List <LabClient> clients, string rdsKeyLocation)
        {
            if (firstCall)
            {
                Service.GetInstance().TransferAndRun(clients);


                iRDSession.OnAttendeeConnected += Incoming;

                iRDSession.Open();
                iRDSession.Resume();
                IRDPSRAPIInvitation pInvitation =
                    iRDSession.Invitations.CreateInvitation("WinPresenter", "PresentationGroup", "", 500);
                var invitationString = pInvitation.ConnectionString;
                var directoryName    = Path.GetDirectoryName(rdsKeyLocation);
                if ((directoryName.Length > 0) && (!Directory.Exists(directoryName)))
                {
                    Directory.CreateDirectory(directoryName);
                }
                var file = new StreamWriter(rdsKeyLocation);

                file.WriteLine(invitationString);
                file.Close();
                firstCall = false;
            }
            else
            {
                Service.GetInstance().TransferAndRun(clients);
                iRDSession.Resume();
            }
        }
コード例 #2
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";
     }
 }
コード例 #3
0
 private void btnShare_Click(object sender, EventArgs e)
 {
     rdpSession.OnAttendeeConnected         += OpenSession;
     rdpSession.OnAttendeeDisconnected      += EndSession;
     rdpSession.OnControlLevelChangeRequest += ControlLevelChange;
     rdpSession.Open();
 }
コード例 #4
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;
                }
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: wj-wong/ArmShareX
        private void HostTabEnterStartConnection()
        {
            RDPSession x = new RDPSession();

            x.OnAttendeeConnected += Incoming;
            x.Open();
        }
コード例 #6
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);
            }
        }
コード例 #7
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;
            }
        }
コード例 #8
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();
 }
コード例 #9
0
ファイル: SharePc.cs プロジェクト: foringH/RDP-Server-V2
        private void connectWithControl()//RDPSession session)
        {
            Console.WriteLine("connecting control");

            currentSession.OnAttendeeConnected    += incomingControl;
            currentSession.OnAttendeeDisconnected += outgoingControl;

            try
            {
                currentSession.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine("the error is in opening connection: " + e);
                throw e;
            }

            //session.Open();
        }
コード例 #10
0
 public void createSession()  //made it non-static
 {
     lock ( _lock ) {
         if (null == currentSession)
         {
             currentSession = new RDPSession();
             currentSession.Open();
         }
     }
 }
コード例 #11
0
 public static void Connect(RDPSession session)
 {
     try
     {
         session.OnAttendeeConnected += Incoming;
         session.Open();
     }
     catch (Exception)
     {
     }
 }
コード例 #12
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);
        }
コード例 #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            textBox3.Text          = GetIP();
            x.OnAttendeeConnected += Incoming;
            x.Open();
            IRDPSRAPIInvitation Invitation = x.Invitations.CreateInvitation("Trial", "MyGroup", "", 10);

            connection = Invitation.ConnectionString;
            Thread serverthread = new Thread(new ThreadStart(serverstart));

            serverthread.Start();
        }
コード例 #14
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));
            }
        }
コード例 #15
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);
            }
        }
コード例 #16
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);
     }
 }
コード例 #17
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>
 }
コード例 #18
0
        public void OpenShare()
        {
            try
            {
                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);

                m_pRdpSession.Open();
                IRDPSRAPIInvitation pInvitation = m_pRdpSession.Invitations.CreateInvitation("WinPresenter", "PresentationGroup", "Password", 1);
                InvitationString = pInvitation.ConnectionString;
            }
            catch (Exception ex) {}
        }
コード例 #19
0
        /**
         * Starts a new RDP session and associates the appropriate event methods (see CreateNewTicklet).
         * */
        private void StartRDPSession()
        {
            if (rdpSession == null)
            {
                rdpSession = new RDPSession();

                rdpSession.OnAttendeeConnected    += new _IRDPSessionEvents_OnAttendeeConnectedEventHandler(OnGuruConnect);
                rdpSession.OnAttendeeDisconnected += new _IRDPSessionEvents_OnAttendeeDisconnectedEventHandler(OnGuruDisconnect);
                // rdpSession.OnControlLevelChangeRequest += new _IRDPSessionEvents_OnControlLevelChangeRequestEventHandler(OnGuruChangeControlLevel);
                rdpSession.Open();
            }
            else
            {
                rdpSession.Resume();
            }
        }
コード例 #20
0
        private void OpenRDC()
        {
            try
            {
                RDPSession _rdpSession = new RDPSession();  // 新建RDP Session

                //_rdpSession.SetDesktopSharedRect(0, 0, 1920, 1080);// 設定共享區域,如果不設定預設為整個螢幕,當然如果有多個螢幕,還是設定下主螢幕,否則,區域會很大

                _rdpSession.Open();                                                                                         // 開啟會話

                IRDPSRAPIInvitation invitation = _rdpSession.Invitations.CreateInvitation("baseAuth", "groupName", "", 64); // 建立申請
                txtConnectString.Text            = invitation.ConnectionString;
                _rdpSession.OnAttendeeConnected += new _IRDPSessionEvents_OnAttendeeConnectedEventHandler(OnAttendeeConnected);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("error {0}", ex.ToString()));
            }
        }
コード例 #21
0
ファイル: WinSharer.cs プロジェクト: wangh1978/WinPresenter
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                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);
                //m_pRdpSession.colordepth = 16;
                m_pRdpSession.Open();
                IRDPSRAPIInvitation pInvitation = m_pRdpSession.Invitations.CreateInvitation("WinPresenter", "PresentationGroup", "", 5);
                string invitationString         = pInvitation.ConnectionString;

                UdpClient UdpSender = new UdpClient(new IPEndPoint(IPAddress.Any, 0));

                byte[] ipByte = System.Text.Encoding.ASCII.GetBytes(invitationString);
                //以下内容参数需要添加配置
                //IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 7788);//默认向全局域网所有主机发送
                //IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("192.168.0.120"), 7788);//向指定主机发送
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(textIp.Text), 7788);//向指定主机发送

                m_Timer.Interval = 3000;

                m_Timer.Tick += delegate
                {
                    UdpSender.Send(ipByte, ipByte.Length, endpoint);
                };

                m_Timer.Start();

                //WriteToFile(invitationString);
                LogTextBox.Text += "开启局域网共享广播." + Environment.NewLine;
            }
            catch (Exception ex)
            {
                LogTextBox.Text += "当前共享广播出错. 错误: " + ex.ToString() + Environment.NewLine;
            }
        }
コード例 #22
0
        public void Start(List <LabClient> clients)
        {
            this.sessionID++;
            Service.getInstance().TransferAndRun(clients);

            x.OnAttendeeConnected += Incoming;
            if (first)
            {
                x.Open();
            }
            else
            {
                x.Resume();
            }

            IRDPSRAPIInvitation Invitation = x.Invitations.CreateInvitation("Trial" + sessionID, "MyGroup" + sessionID, "", 50);
            String Contents = Invitation.ConnectionString.Trim();

            System.IO.StreamWriter file = new System.IO.StreamWriter(rdsKeyLocation);
            file.WriteLine(Contents);
            file.Close();

            first = false;
        }
コード例 #23
0
ファイル: Form1.cs プロジェクト: ragnleach/HJewel2
        public Form1()
        {
            InitializeComponent();
            // Create a simple tray menu with only one item.
            trayMenu = new ContextMenu();
            trayMenu.MenuItems.Add("Exit", OnExit);

            // Create a tray icon. In this example we use a
            // standard system icon for simplicity, but you
            // can of course use your own custom icon too.
            trayIcon      = new NotifyIcon();
            trayIcon.Text = "Jewel";
            trayIcon.Icon = new Icon(SystemIcons.WinLogo, 40, 40);

            // Add menu to tray icon and show it.
            trayIcon.ContextMenu   = trayMenu;
            trayIcon.Visible       = true;
            s.OnAttendeeConnected += Incoming;
            s.Open();
            IRDPSRAPIInvitation Invitation = s.Invitations.CreateInvitation("Test01", "MyGroup", "", 2);
            string invitetext = Invitation.ConnectionString;

            sendmail(invitetext, System.Environment.MachineName);
        }
コード例 #24
0
        private void buttonShareScreen_click(object sender, RoutedEventArgs e)
        {
            Button     b    = sender as Button;
            FriendData data = b.CommandParameter as FriendData;

            if (data.Status && !ClientInformation.ShareScreenWindows.ContainsKey(data.Username))
            {
                if (RdpSession == null)
                {
                    RdpSession = new RDPSession();
                    RdpSession.OnAttendeeConnected += Incoming;
                    RdpSession.Open();
                }
                IRDPSRAPIInvitation Invitation = RdpSession.Invitations.CreateInvitation("auth" + ClientInformation.authNr++, "group" + ClientInformation.groupNr++, "", 1);
                ClientInformation.authNr++;
                ClientInformation.groupNr++;

                ClientInformation.ScreenShareService.InitShareScreen(ClientInformation.Username, data.Username, Invitation.ConnectionString);

                ShareScreenEnding window = new ShareScreenEnding(data.Username, false);
                ClientInformation.ShareScreenEndingWindows.Add(data.Username, window);
                window.Show();
            }
        }
コード例 #25
0
 public void Connect()
 {
     currentSession.OnAttendeeConnected    += Incoming;
     currentSession.OnAttendeeDisconnected += Disconnect;
     currentSession.Open();
 }
コード例 #26
0
 //access to COM/firewall will prompt
 private void button1_Click(object sender, EventArgs e)
 {
     x.OnAttendeeConnected += Incoming;
     x.Open();
 }
コード例 #27
0
        public void Open()
        {
            if (IsStart)
            {
                return;
            }

            lock (locker)
            {
                if (IsStart)
                {
                    return;
                }

                IsStart = true;
                Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + ":" + "正在开启服务,请稍等……");
                // 新建RDP Session
                _rdpSession            = new RDPSession();
                _rdpSession.colordepth = 24;

                bool find = false;
                this.SourceRect = new Rect(Properties.Settings.Default.MonitorArea);
                if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.Application))
                {
                    this.Monitor = new System.Threading.Thread(new System.Threading.ThreadStart(MonitorPosition));
                    this.Monitor.Start();

                    foreach (IRDPSRAPIApplication app in _rdpSession.ApplicationFilter.Applications)
                    {
                        if (string.IsNullOrWhiteSpace(app.Name) ||
                            app.Name?.ToLower() == Properties.Settings.Default.Application?.ToLower())
                        {
                            if (!this.IsLegal(app.Id, app))
                            {
                                continue;
                            }

                            find = true;
                        }
                    }
                }


                // 设置共享区域,如果不设置默认为整个屏幕,当然如果有多个屏幕,还是设置下主屏幕,否则,区域会很大
                if (!find && !string.IsNullOrWhiteSpace(Properties.Settings.Default.Application))
                {
                    Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + ":" + "系统中没有发现需要监控的应用程序[" + Properties.Settings.Default.Application + "], 暂时监控默认区域。");
                }

                if (Properties.Settings.Default.MonitorArea.Width > 0 &&
                    Properties.Settings.Default.MonitorArea.Height > 0)
                {
                    this.SetDesktopSharedRect(this.SourceRect);
                }

                _rdpSession.OnAttendeeConnected    += _rdpSession_OnAttendeeConnected;
                _rdpSession.OnAttendeeDisconnected += _rdpSession_OnAttendeeDisconnected;

                _rdpSession.OnControlLevelChangeRequest += RdpSessionOnOnControlLevelChangeRequest;

                _rdpSession.OnApplicationOpen  += _rdpSession_OnApplicationOpen;
                _rdpSession.OnApplicationClose += _rdpSession_OnApplicationClose;

                _rdpSession.OnGraphicsStreamPaused  += _rdpSession_OnGraphicsStreamPaused;
                _rdpSession.OnGraphicsStreamResumed += _rdpSession_OnGraphicsStreamResumed;
                // 打开会话
                _rdpSession.Open();

                Invitation = _rdpSession.Invitations.CreateInvitation(Environment.MachineName, Environment.UserName, "Cepg@2012", 64);  // 创建申请

                RHost = new ServiceHost(typeof(RDPService));
                RHost.Open();
                Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + ":" + "服务开启完成!");
            }
        }
コード例 #28
0
ファイル: RdpSessionServer.cs プロジェクト: Heide172/dpR
 /// <summary>
 /// Puts the session in an active state and starts listening to incoming connections.
 /// </summary>
 public void Open()
 {
     _rdpSession.Open();
 }
コード例 #29
0
 public static void Connect(RDPSession session)
 {
     session.OnAttendeeConnected += Incoming;
     session.Open();
 }
コード例 #30
0
        private void button1_Click(object sender, EventArgs e)
        {
            StartButton.Enabled = false;

            try
            {
                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);
                //m_pRdpSession
                m_pRdpSession.Open();
                IRDPSRAPIInvitation pInvitation = m_pRdpSession.Invitations.CreateInvitation("WJB_RemoteDesktop_Application", "LAN_Network", "2314", 1);

                //use port 14242


                //NetManager.EstablishConnection();

                //NetManager.ReceiveConnection();


                //textBox2.AppendText(m_pRdpSession.Attendees.ToString() + Environment.NewLine);
                string invitationString = pInvitation.ConnectionString;
                WriteToFile(invitationString);
                //LogTextBox.Text += "Presentation Started. Your Desktop is being shared." + Environment.NewLine;
                //LogTextBox.AppendText("Presentation Started. Your Desktop is being shared." + Environment.NewLine);
                LogTextBox.AppendText("Starting . . ." + Environment.NewLine);

                //NetManager propTest = new NetManager("defaultMessage", null, false, 0);
                NetManager propTest = new NetManager();

                Thread netManager = new Thread(new ThreadStart(propTest.RunExample));

                netManager.Start();

                //Thread.Sleep(2500);

                while (!File.Exists("listeners.xml"))
                {
                    //LogTextBox.AppendText("Waiting for inv.xml to be written to file." + Environment.NewLine);
                }

                /*while (IsFileLocked("listeners.xml") == true)
                 * {
                 *  LogTextBox.AppendText(IsFileLocked("listeners.xml") + Environment.NewLine);
                 * }*/

                while (IsFileEmpty("listeners.xml") == true)
                {
                    //wait
                }


                //IsFileLocked("listeners.xml");

                //LogTextBox.AppendText(IsFileLocked("listeners.xml") + Environment.NewLine);

                //Thread.Sleep(5000);

                LogTextBox.AppendText("Presentation Started. Your Desktop is ready to be shared." + Environment.NewLine);

                string[] listeners = File.ReadAllLines("listeners.xml");

                foreach (var item in listeners)
                {
                    //Console.WriteLine(item.ToString());
                    LogTextBox.AppendText(item + Environment.NewLine);
                }

                StopButton.Enabled = true;
            }
            catch (Exception ex)
            {
                //LogTextBox.Text += "Error occured while starting presentation. Error: " + ex.ToString() + Environment.NewLine;
                LogTextBox.AppendText("Error occured while starting presentation. Error: " + ex.ToString() + Environment.NewLine);
            }
        }