コード例 #1
0
	/// <summary>
	/// We are ready to create a session.  Ensure the data is valid
	/// then create the session
	/// </summary>
	private void btnOK_Click(object sender, System.EventArgs e) {
		ApplicationDescription dpApp;
		if ((txtSession.Text == null) || (txtSession.Text == "")) {
			MessageBox.Show(this,"Please enter a session name before clicking OK.","No sessionname",MessageBoxButtons.OK,MessageBoxIcon.Information);
			return;
		}

		Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\DirectX\\SDK\\csDPlay");
		if (regKey != null) {
			regKey.SetValue("DirectPlaySessionName", txtSession.Text);
			if (migrateHostCheckBox.Checked)
				regKey.SetValue("DirectPlayMigrateHost",1);
			else
				regKey.SetValue("DirectPlayMigrateHost",0);

			if (fastSignedRadio.Checked)
				regKey.SetValue("DirectPlaySessionSigning","Fast");
			else if (fullSignedRadio.Checked)
				regKey.SetValue("DirectPlaySessionSigning","Full");
			else
				regKey.SetValue("DirectPlaySessionSigning","Disabled");
			regKey.Close();
		}

		dpApp = new ApplicationDescription();
		dpApp.GuidApplication = connectionWizard.ApplicationGuid;
		dpApp.SessionName = txtSession.Text;
		dpApp.Flags = 0;
    
		if (migrateHostCheckBox.Checked)
			dpApp.Flags |= SessionFlags.MigrateHost;

		if (!useDPNSVRCheckBox.Checked)
			dpApp.Flags |= SessionFlags.NoDpnServer;

		if (fastSignedRadio.Checked)
			dpApp.Flags |= SessionFlags.FastSigned;
		else if (fullSignedRadio.Checked)
			dpApp.Flags |= SessionFlags.FullSigned;

		// Specify the port number if available
		if (ConnectWizard.ProviderRequiresPort(deviceAddress.ServiceProvider)) {
			if (Port > 0)
				deviceAddress.AddComponent(Address.KeyPort, Port);
		}

		connectionWizard.SetUserInfo();
		// Host a game on deviceAddress as described by dpApp
		// HostFlags.OkToQueryForAddressing allows DirectPlay to prompt the user
		// using a dialog box for any device address information that is missing
		peer.Host(dpApp,deviceAddress,HostFlags.OkToQueryForAddressing);
		this.DialogResult = DialogResult.OK;
	}
コード例 #2
0
ファイル: DPlayConnect_JoinForm.cs プロジェクト: sjk7/DX90SDK
    /// <summary>
    /// Join an existing session
    /// </summary>
    private void btnJoin_Click(object sender, System.EventArgs e)
    {
        FindHostsResponseInformation dpInfo;

        if (lstSession.SelectedItem == null)
        {
            MessageBox.Show(this, "Please select a session before clicking join.", "No session", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return;
        }

        // Turn off all buttons
        btnCreate.Enabled = false;
        btnCancel.Enabled = false;
        btnJoin.Enabled   = false;
        btnSearch.Enabled = false;
        amJoining         = true;
        // Stop our secondary timer
        updateListTimer.Stop();
        dpInfo = ((FindHostsResponseInformation)lstSession.SelectedItem);
        connectionWizard.SetUserInfo();
        peer.Connect(dpInfo.ApplicationDesc, dpInfo.sender, dpInfo.device, null, ConnectFlags.OkToQueryForAddressing);
        // Now start our 'Connect' timer
        connectTimer.Start();
    }