예제 #1
0
파일: ThreadPool.cs 프로젝트: sjk7/DX90SDK
        /// <summary>
        /// Connect to the currently selected session
        /// </summary>
        public void ConnectToSession()
        {
            // Display connection dialog
            ConnectDialog dialog = new ConnectDialog(this);

            dialog.RemotePort = DefaultPort;

            if (DialogResult.Cancel == dialog.ShowDialog())
            {
                return;
            }

            // Update the UI
            myForm.SessionStatusLabel.Text = "Connecting...";
            myForm.Update();

            // Store connection dialog choices
            HostInfo SelectedHost = dialog.SelectedHost;

            if (SelectedHost == null)
            {
                return;
            }

            // Create an application description object to hold the desired
            // host's instance guid.
            ApplicationDescription appDesc = new ApplicationDescription();

            appDesc.GuidInstance = SelectedHost.GuidInstance;

            // Attempt to connect to the selected DirectPlay session. Once we
            // are connected to the session, we will receive DirectPlay messages
            // about session events (like players joining/exiting and received game
            // data). Since we're passing in the "Sync" flag, the Connect call will
            // block until the session is connected or the timeout expires.
            try
            {
                myPeer.Connect(appDesc,                  // Application description
                               SelectedHost.HostAddress, // Host address
                               localAddress,             // Local device address
                               null,                     // User connection data (none)
                               ConnectFlags.Sync);       // Flags

                sessionName  = SelectedHost.SessionName;
                myConnection = ConnectionType.Connected;
            }
            catch (Exception ex)
            {
                myForm.ShowException(ex, "Connect", false);
                return;
            }
        }
예제 #2
0
파일: ThreadPool.cs 프로젝트: sjk7/DX90SDK
        //---------------------------------------------------------------------
        #endregion // DirectPlay Object Initializations

        #region DirectPlay Event Handlers
        //---------------------------------------------------------------------

        /// <summary>
        /// Event handler for the DirectPlay FindHostResponse message
        /// </summary>
        public void FindHostResponseHandler(object sender, FindHostResponseEventArgs args)
        {
            HostInfo Node = new HostInfo();

            Node.GuidInstance = args.Message.ApplicationDescription.GuidInstance;
            Node.HostAddress  = (Address)args.Message.AddressSender.Clone();
            Node.SessionName  = args.Message.ApplicationDescription.SessionName;

            // If he haven't already seen this host, add the detected session
            // to the stored list
            if (!myFoundSessions.Contains(Node))
            {
                myFoundSessions.Add(Node);
            }
        }
예제 #3
0
 /// <summary>
 /// Handler for Connect button click
 /// </summary>
 private void ConnectButton_Click(object sender, System.EventArgs e)
 {
     // Save the current settings
     mySelectedHost = (HostInfo)DetectedSessionsListBox.SelectedItem;
     DialogResult   = DialogResult.OK;
 }
예제 #4
0
파일: HostInfo.cs 프로젝트: sjk7/DX90SDK
        public string SessionName;  // Display name for the session

        /// <summary>
        /// Used by the system collection class
        /// </summary>
        public override bool Equals(object obj)
        {
            HostInfo node = (HostInfo)obj;

            return(GuidInstance.Equals(node.GuidInstance));
        }