/// <summary>
    /// Constructor
    /// </summary>
    public CreateJoinForm(Peer peerObject, Address addressObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        peer = peerObject;
        this.connectionWizard = connectionWizard;
        this.Text = connectionWizard.SampleName + " - " + this.Text;
        deviceAddress = addressObject;

        //Set up the event handlers
        peer.FindHostResponse += new FindHostResponseEventHandler(FindHostResponseMessage);
        peer.ConnectComplete += new ConnectCompleteEventHandler(ConnectResult);
        peer.AsyncOperationComplete += new AsyncOperationCompleteEventHandler(CancelAsync);

        //Set up our timer
        updateListTimer = new System.Timers.Timer(300); // A 300 ms interval
        updateListTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.UpdateTimer);
        updateListTimer.SynchronizingObject = this;
        updateListTimer.Start();
        //Set up our connect timer
        connectTimer = new System.Timers.Timer(100); // A 100ms interval
        connectTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.ConnectTimer);
        connectTimer.SynchronizingObject = this;
        // Set up our connect event
        connectEvent = new ManualResetEvent(false);
    }
示例#2
0
    /// <summary>
    /// Constructor
    /// </summary>
    public CreateJoinForm(Peer peerObject, Address addressObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        peer = peerObject;
        this.connectionWizard = connectionWizard;
        this.Text             = connectionWizard.SampleName + " - " + this.Text;
        deviceAddress         = addressObject;

        //Set up the event handlers
        peer.FindHostResponse       += new FindHostResponseEventHandler(FindHostResponseMessage);
        peer.ConnectComplete        += new ConnectCompleteEventHandler(ConnectResult);
        peer.AsyncOperationComplete += new AsyncOperationCompleteEventHandler(CancelAsync);

        //Set up our timer
        updateListTimer                     = new System.Timers.Timer(300); // A 300 ms interval
        updateListTimer.Elapsed            += new System.Timers.ElapsedEventHandler(this.UpdateTimer);
        updateListTimer.SynchronizingObject = this;
        updateListTimer.Start();
        //Set up our connect timer
        connectTimer                     = new System.Timers.Timer(100); // A 100ms interval
        connectTimer.Elapsed            += new System.Timers.ElapsedEventHandler(this.ConnectTimer);
        connectTimer.SynchronizingObject = this;
        // Set up our connect event
        connectEvent = new ManualResetEvent(false);
    }
示例#3
0
    public PlayClass(GameClass Game)
    {
        this.game = Game;

        //Initialize our peer to peer network object
        peerObject = new Peer();


        // Set up our event handlers (We only need events for the ones we care about)
        peerObject.PlayerCreated     += new PlayerCreatedEventHandler(PlayerCreated);
        peerObject.PlayerDestroyed   += new PlayerDestroyedEventHandler(PlayerDestroyed);
        peerObject.Receive           += new ReceiveEventHandler(game.DataReceived);
        peerObject.SessionTerminated += new SessionTerminatedEventHandler(SessionTerminated);

        // use the DirectPlay connection wizard to create our join sessions
        Connect = new ConnectWizard(peerObject, AppGuid, "Spacewar3D");
        Connect.StartWizard();

        inSession = Connect.InSession;

        if (inSession)
        {
            isHost = Connect.IsHost;
        }
    }
        /// <summary>
        /// Constructs a recent profile selection wizard page.
        /// </summary>
        /// <param name="wizard">The connecting wizard</param>
        public RecentConfigurationSelectPage(ConnectWizard wizard) :
            base(wizard)
        {
            // Create history panels.
            Panels = new ConnectingSelectPanel[Wizard.InstanceSources.Length];
            for (var source_index = (int)InstanceSourceType._start; source_index < (int)InstanceSourceType._end; source_index++)
            {
                if (Wizard.InstanceSources[source_index] is LocalInstanceSource)
                {
                    switch (Properties.Settings.Default.ConnectingProfileSelectMode)
                    {
                    case 0: Panels[source_index] = new ConnectingProfileSelectPanel(Wizard, (InstanceSourceType)source_index); break;

                    case 1: Panels[source_index] = new ConnectingInstanceSelectPanel(Wizard, (InstanceSourceType)source_index); break;

                    case 2: Panels[source_index] = new ConnectingProfileSelectPanel(Wizard, (InstanceSourceType)source_index); break;

                    case 3: Panels[source_index] = new ConnectingInstanceAndProfileSelectPanel(Wizard, (InstanceSourceType)source_index); break;
                    }
                }
                else if (
                    Wizard.InstanceSources[source_index] is DistributedInstanceSource ||
                    Wizard.InstanceSources[source_index] is FederatedInstanceSource)
                {
                    Panels[source_index] = new ConnectingInstanceAndProfileSelectPanel(Wizard, (InstanceSourceType)source_index);
                }
            }
        }
    /// <summary>
    /// Constructor
    /// </summary>
    public ChooseServiceProviderForm(Peer peerObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        peer = peerObject;
        this.connectionWizard = connectionWizard;
        this.Text = connectionWizard.SampleName + " - " + this.Text;
        // Fill up our listbox with the service providers
        ServiceProviderInformation[] serviceProviders = peer.GetServiceProviders(false);
        foreach (ServiceProviderInformation info in serviceProviders)
            lstSP.Items.Add(info);

        txtUser.Text = null;
        //Get the default username from the registry if it exists
        Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\DirectX\\SDK\\csDPlay");
        if (regKey != null) {
            try {
                txtUser.Text = (string)regKey.GetValue("DirectPlayUserName", null);
                lstSP.SelectedIndex = (int)regKey.GetValue("DirectPlaySPIndex", 0);
                regKey.Close();
            }
            catch {
                txtUser.Text = null;
                lstSP.SelectedIndex = 0;
            }
        }
        else
            lstSP.SelectedIndex = 0;

        if ((txtUser.Text == null) || (txtUser.Text == "")) {
            txtUser.Text = SystemInformation.UserName;
        }
    }
示例#6
0
 /// <inheritdoc/>
 public override void FromSettings(ConnectWizard wizard, Xml.InstanceSourceSettingsBase settings)
 {
     if (settings is Xml.FederatedInstanceSourceSettings h_federated)
     {
         // - Restore connecting instance (optional).
         ConnectingInstance = SelectConnectingInstance(h_federated.ConnectingInstance);
     }
 }
示例#7
0
        /// <summary>
        /// Constructs a panel
        /// </summary>
        /// <param name="wizard">The connecting wizard</param>
        /// <param name="instance_source_type">Instance source type</param>
        public ConnectingRefreshableProfileListSelectPanel(ConnectWizard wizard, InstanceSourceType instance_source_type) :
            base(wizard, instance_source_type)
        {
            // Trigger initial load.
            OnPropertyChanged(this, new PropertyChangedEventArgs(nameof(SelectedInstance)));

            // Register to receive property change events and reload the profile list.
            PropertyChanged += OnPropertyChanged;
        }
示例#8
0
 /// <summary>
 /// Creates an WireGuard session
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 /// <param name="connectingProfile">Connecting eduVPN profile</param>
 /// <param name="profileConfig">Initial profile configuration</param>
 public WireGuardSession(ConnectWizard wizard, Profile connectingProfile, Xml.Response profileConfig) :
     base(wizard, connectingProfile, profileConfig)
 {
     TunnelName = connectingProfile.Server.Base.Host;
     if (TunnelName.Length > 32)
     {
         TunnelName = TunnelName.Substring(0, 32);
     }
     DeactivateInProgress = new CancellationTokenSource();
 }
示例#9
0
        /// <summary>
        /// Constructs a wizard page.
        /// </summary>
        /// <param name="wizard">The connecting wizard</param>
        public SearchPage(ConnectWizard wizard) :
            base(wizard)
        {
            Wizard.DiscoveredServersChanged += (object sender, EventArgs e) =>
            {
                _ConfirmOrganizationSelection?.RaiseCanExecuteChanged();
                Search();
            };

            Wizard.DiscoveredOrganizationsChanged += (object sender, EventArgs e) => Search();
        }
示例#10
0
 /// <summary>
 /// Constructs a wizard page.
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 public SelectOwnServerPage(ConnectWizard wizard) :
     base(wizard)
 {
     PropertyChanged += (object sender, PropertyChangedEventArgs e) =>
     {
         if (e.PropertyName == nameof(HasErrors))
         {
             _AddServer?.RaiseCanExecuteChanged();
         }
     };
 }
        /// <summary>
        /// Construct a panel
        /// </summary>
        /// <param name="wizard">The connecting wizard</param>
        /// <param name="authenticating_instance">Authenticating instance</param>
        public TwoFactorAuthenticationBasePanel(ConnectWizard wizard, Instance authenticating_instance) :
            base(wizard)
        {
            AuthenticatingInstance = authenticating_instance;

            // Create dispatcher timer.
            _previous_response_time_updater = new DispatcherTimer(
                new TimeSpan(0, 0, 0, 1),
                DispatcherPriority.Normal, (object sender, EventArgs e) => RaisePropertyChanged(nameof(LastResponseTime)),
                Wizard.Dispatcher);
        }
示例#12
0
    /// <summary>
    /// Constructor
    /// </summary>
    public CreateSessionForm(Peer peerObject, Address addressObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();

        peer = peerObject;
        this.connectionWizard = connectionWizard;
        deviceAddress         = addressObject;
        txtSession.Text       = null;
        this.Text             = connectionWizard.SampleName + " - " + this.Text;
        //Get the default session from the registry if it exists
        Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\DirectX\\SDK\\csDPlay");
        if (regKey != null)
        {
            // Get session name
            txtSession.Text = (string)regKey.GetValue("DirectPlaySessionName", null);

            // Get host migration option
            if (regKey.GetValue("DirectPlayMigrateHost", null) != null)
            {
                migrateHostCheckBox.Checked = ((int)regKey.GetValue("DirectPlayMigrateHost", 1) == 1);
            }


            // Get session signing option
            if (regKey.GetValue("DirectPlaySessionSigning", null) != null)
            {
                if ("Full" == (string)regKey.GetValue("DirectPlaySessionSigning", null))
                {
                    fullSignedRadio.Checked = true;
                }
                else if ("Fast" == (string)regKey.GetValue("DirectPlaySessionSigning", null))
                {
                    fastSignedRadio.Checked = true;
                }
                else
                {
                    notSignedRadio.Checked = true;
                }
            }

            regKey.Close();
        }

        // Set default port value and hide port UI if provider doesn't use them
        Port = connectionWizard.DefaultPort;
        if (!ConnectWizard.ProviderRequiresPort(deviceAddress.ServiceProvider))
        {
            localPortTextBox.Hide();
            localPortLabel.Hide();
        }
    }
示例#13
0
 /// <summary>
 /// Constructs an profile selection wizard page.
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 public ConnectingProfileSelectPage(ConnectWizard wizard) :
     base(wizard)
 {
     Wizard.PropertyChanged += (object sender, PropertyChangedEventArgs e) =>
     {
         if (e.PropertyName == nameof(Wizard.InstanceSourceType))
         {
             RaisePropertyChanged(nameof(Panel));
         }
     };
 }
	/// <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;
	}
示例#15
0
        /// <summary>
        /// Constructs a wizard page.
        /// </summary>
        /// <param name="wizard">The connecting wizard</param>
        public HomePage(ConnectWizard wizard) :
            base(wizard)
        {
            RebuildInstituteAccessServers(this, null);
            RebuildSecureInternetServers(this, null);
            RebuildOwnServers(this, null);

            Wizard.DiscoveredServersChanged += (object sender, EventArgs e) =>
            {
                RebuildInstituteAccessServers(sender, e);
                RebuildSecureInternetServers(sender, e);
                RebuildOwnServers(sender, e);
            };
            Wizard.DiscoveredOrganizationsChanged += RebuildSecureInternetServers;
        }
示例#16
0
        /// <inheritdoc/>
        public override void FromSettings(ConnectWizard wizard, Xml.InstanceSourceSettingsBase settings)
        {
            if (settings is Xml.DistributedInstanceSourceSettings h_distributed)
            {
                // - Restore authenticating instance.
                // - Restore connecting instance (optional).
                AuthenticatingInstance = h_distributed.AuthenticatingInstance != null?InstanceList.FirstOrDefault(inst => inst.Base.AbsoluteUri == h_distributed.AuthenticatingInstance.AbsoluteUri) : null;

                if (AuthenticatingInstance != null)
                {
                    AuthenticatingInstance.RequestAuthorization += wizard.Instance_RequestAuthorization;
                    AuthenticatingInstance.ForgetAuthorization  += wizard.Instance_ForgetAuthorization;
                    ConnectingInstance = SelectConnectingInstance(h_distributed.ConnectingInstance);
                }
            }
        }
    /// <summary>
    /// Constructor
    /// </summary>
    public CreateSessionForm(Peer peerObject, Address addressObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();

        peer = peerObject;
        this.connectionWizard = connectionWizard;
        deviceAddress = addressObject;
        txtSession.Text = null;
        this.Text = connectionWizard.SampleName + " - " + this.Text;
        //Get the default session from the registry if it exists
        Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\DirectX\\SDK\\csDPlay");
        if (regKey != null)
        {
            // Get session name
            txtSession.Text = (string)regKey.GetValue("DirectPlaySessionName", null);

            // Get host migration option
            if (regKey.GetValue("DirectPlayMigrateHost",null) != null)
            {
                migrateHostCheckBox.Checked = ((int)regKey.GetValue("DirectPlayMigrateHost",1)==1);
            }

            // Get session signing option
            if (regKey.GetValue("DirectPlaySessionSigning",null) != null)
            {
                if ("Full" == (string)regKey.GetValue("DirectPlaySessionSigning",null))
                    fullSignedRadio.Checked = true;
                else if ("Fast" == (string)regKey.GetValue("DirectPlaySessionSigning",null))
                    fastSignedRadio.Checked = true;
                else
                    notSignedRadio.Checked = true;
            }

            regKey.Close();
        }

        // Set default port value and hide port UI if provider doesn't use them
        Port = connectionWizard.DefaultPort;
        if (!ConnectWizard.ProviderRequiresPort(deviceAddress.ServiceProvider))
        {
            localPortTextBox.Hide();
            localPortLabel.Hide();
        }
    }
示例#18
0
        /// <summary>
        /// Constructs a panel
        /// </summary>
        /// <param name="wizard">The connecting wizard</param>
        /// <param name="instance_source_type">Instance source type</param>
        public ConnectingSelectPanel(ConnectWizard wizard, InstanceSourceType instance_source_type) :
            base(wizard)
        {
            InstanceSourceType = instance_source_type;

            PropertyChanged += (object sender, PropertyChangedEventArgs e) =>
            {
                if (e.PropertyName == nameof(SelectedInstance))
                {
                    RaisePropertyChanged(nameof(ForgetSelectedInstanceLabel));
                }
                else if (e.PropertyName == nameof(SelectedProfile))
                {
                    RaisePropertyChanged(nameof(ForgetSelectedProfileLabel));
                }
            };
        }
示例#19
0
        /// <summary>
        /// Creates a VPN session
        /// </summary>
        /// <param name="wizard">The connecting wizard</param>
        /// <param name="connectingProfile">Connecting eduVPN profile</param>
        public Session(ConnectWizard wizard, Profile connectingProfile) :
            this()
        {
            SessionAndWindowInProgress = CancellationTokenSource.CreateLinkedTokenSource(SessionInProgress.Token, Window.Abort.Token);

            Wizard            = wizard;
            ConnectingProfile = connectingProfile;
            State             = SessionStatusType.Initializing;

            // Create dispatcher timer.
            ConnectedTimeUpdater = new DispatcherTimer(
                new TimeSpan(0, 0, 0, 1),
                DispatcherPriority.Normal,
                (object sender, EventArgs e) => RaisePropertyChanged(nameof(ConnectedTime)),
                Wizard.Dispatcher);
            ConnectedTimeUpdater.Start();
        }
示例#20
0
文件: wfChat.cs 项目: sjk7/DX90SDK
        /// <summary>
        /// Constuctor
        /// </summary>
        public ChatPeer()
        {
            try
            {
                // Load the icon from our resources
                System.Resources.ResourceManager resources = new System.Resources.ResourceManager(this.GetType());
                this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            }
            catch
            {
                // It's no big deal if we can't load our icons, but try to load the embedded one
                try { this.Icon = new System.Drawing.Icon(this.GetType(), "directx.ico"); }
                catch {}
            }

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            peerObject = new Peer();
            // First set up our event handlers (We only need events for the ones we care about)
            peerObject.PlayerCreated     += new PlayerCreatedEventHandler(this.PlayerCreated);
            peerObject.PlayerDestroyed   += new PlayerDestroyedEventHandler(this.PlayerDestroyed);
            peerObject.HostMigrated      += new HostMigratedEventHandler(this.HostMigrated);
            peerObject.Receive           += new ReceiveEventHandler(this.DataReceived);
            peerObject.SessionTerminated += new SessionTerminatedEventHandler(this.SessionTerminated);
            connectWizard = new ConnectWizard(peerObject, localApplicationGuid, "Chat Peer");

            connectWizard.DefaultPort = DefaultPort;
            if (connectWizard.StartWizard())
            {
                // Great we've connected (or joined)..  Now we can start the sample
                // Are we the host?
                if (connectWizard.IsHost)
                {
                    this.Text += " (HOST)";
                }
            }
            else
            {
                // We obviously didn't want to start a session
                this.Dispose();
            }
        }
    /// <summary>
    /// Constructor
    /// </summary>
    public ChooseServiceProviderForm(Peer peerObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        peer = peerObject;
        this.connectionWizard = connectionWizard;
        this.Text             = connectionWizard.SampleName + " - " + this.Text;
        // Fill up our listbox with the service providers
        ServiceProviderInformation[] serviceProviders = peer.GetServiceProviders(false);
        foreach (ServiceProviderInformation info in serviceProviders)
        {
            lstSP.Items.Add(info);
        }

        txtUser.Text = null;
        //Get the default username from the registry if it exists
        Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\DirectX\\SDK\\csDPlay");
        if (regKey != null)
        {
            try
            {
                txtUser.Text        = (string)regKey.GetValue("DirectPlayUserName", null);
                lstSP.SelectedIndex = (int)regKey.GetValue("DirectPlaySPIndex", 0);
                regKey.Close();
            }
            catch
            {
                txtUser.Text        = null;
                lstSP.SelectedIndex = 0;
            }
        }
        else
        {
            lstSP.SelectedIndex = 0;
        }

        if ((txtUser.Text == null) || (txtUser.Text == ""))
        {
            txtUser.Text = SystemInformation.UserName;
        }
    }
    public PlayClass(GameClass parent)
    {
        this.parent = parent;
        this.peerObject = peerObject;
        this.message = new MessageDelegate(parent.MessageArrived);

        peerObject = new Peer();
        // First set up our event handlers (We only need events for the ones we care about)
        peerObject.PlayerCreated += new PlayerCreatedEventHandler(this.PlayerCreated);
        peerObject.PlayerDestroyed += new PlayerDestroyedEventHandler(this.PlayerDestroyed);
        peerObject.HostMigrated += new HostMigratedEventHandler(this.HostMigrated);
        peerObject.Receive += new ReceiveEventHandler(this.DataReceived);
        peerObject.SessionTerminated += new SessionTerminatedEventHandler(this.SessionTerminated);

        Connect = new ConnectWizard(peerObject, AppGuid, "Step2");
        if (!Connect.StartWizard()) {
            MessageBox.Show("DirectPlay initialization was incomplete. Application will terminate.");
            throw new DirectXException();
        }
    }
 /// <summary>
 /// Constructs a panel
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 /// <param name="instance_source_type">Instance source type</param>
 public ConnectingRefreshableProfileSelectPanel(ConnectWizard wizard, InstanceSourceType instance_source_type) :
     base(wizard, instance_source_type)
 {
     PropertyChanged += (object sender, PropertyChangedEventArgs e) =>
     {
         if (e.PropertyName == nameof(ProfileList) &&
             ProfileList != null &&
             ProfileList.Count == 1 &&
             Wizard.Error == null)
         {
             // The profile list has been loaded with exactly one profile available.
             // And there is no error condition to report.
             // Therefore, auto-select the profile and connect!
             SelectedProfile = ProfileList[0];
             if (ConnectSelectedProfile.CanExecute())
             {
                 ConnectSelectedProfile.Execute();
             }
         }
     };
 }
    public PlayClass(GameClass parent)
    {
        this.parent     = parent;
        this.peerObject = peerObject;
        this.message    = new MessageDelegate(parent.MessageArrived);

        peerObject = new Peer();
        // First set up our event handlers (We only need events for the ones we care about)
        peerObject.PlayerCreated     += new PlayerCreatedEventHandler(this.PlayerCreated);
        peerObject.PlayerDestroyed   += new PlayerDestroyedEventHandler(this.PlayerDestroyed);
        peerObject.HostMigrated      += new HostMigratedEventHandler(this.HostMigrated);
        peerObject.Receive           += new ReceiveEventHandler(this.DataReceived);
        peerObject.SessionTerminated += new SessionTerminatedEventHandler(this.SessionTerminated);

        Connect = new ConnectWizard(peerObject, AppGuid, "Step2");
        if (!Connect.StartWizard())
        {
            MessageBox.Show("DirectPlay initialization was incomplete. Application will terminate.");
            throw new DirectXException();
        }
    }
    public PlayClass(GameClass Game)
    {
        this.game = Game;

        //Initialize our peer to peer network object
        peerObject = new Peer();

        // Set up our event handlers (We only need events for the ones we care about)
        peerObject.PlayerCreated += new PlayerCreatedEventHandler(PlayerCreated);
        peerObject.PlayerDestroyed += new PlayerDestroyedEventHandler(PlayerDestroyed);
        peerObject.Receive += new ReceiveEventHandler(game.DataReceived);
        peerObject.SessionTerminated += new SessionTerminatedEventHandler(SessionTerminated);

        // use the DirectPlay connection wizard to create our join sessions
        Connect = new ConnectWizard(peerObject, AppGuid, "Spacewar3D");
        Connect.StartWizard();

        inSession = Connect.InSession;

        if (inSession) {
            isHost = Connect.IsHost;
        }
    }
示例#26
0
        public NETPlayer(GameWorld gameworld)
        {
            //
            // TODO: Add constructor logic here
            //
            game       = gameworld;
            peerObject = new Peer();

            peerObject.PlayerCreated     += new PlayerCreatedEventHandler(game.PlayerCreated);
            peerObject.PlayerDestroyed   += new PlayerDestroyedEventHandler(game.PlayerDestroyed);
            peerObject.Receive           += new ReceiveEventHandler(game.DataReceived);
            peerObject.SessionTerminated += new SessionTerminatedEventHandler(SessionTerminated);

            Connect = new ConnectWizard(peerObject, AppGuid, "Helikopter");
            Connect.StartWizard();

            inSession = Connect.InSession;

            if (inSession)
            {
                isHost = Connect.IsHost;
            }
        }
示例#27
0
 /// <summary>
 /// Construct a panel
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 public Panel(ConnectWizard wizard)
 {
     Wizard = wizard;
 }
示例#28
0
 /// <summary>
 /// Constructs a view model.
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 public AuthorizationPage(ConnectWizard wizard) :
     base(wizard)
 {
 }
        /*public void Host(string sessionName)
        {
            Address hostAddress = new Address();
            hostAddress.ServiceProvider = Address.ServiceProviderTcpIp;
            // Select TCP/IP service provider

            ApplicationDescription dpApp = new ApplicationDescription();
            dpApp.Flags = SessionFlags.FastSigned;
            dpApp.GuidApplication = Guid.NewGuid();     // Set the application GUID
            dpApp.SessionName = sessionName;            // Optional Session Name

            peer.Host(dpApp, hostAddress, HostFlags.OkToQueryForAddressing);
        }*/
        public bool DoWizzard()
        {
            ConnectWizard connectWizard = new ConnectWizard(peer, new Guid("ED48D6E8-91D1-4cf6-9ED3-CB427F76F17D"), "Tglrf");
            connectWizard.DefaultPort = 10293;
            return connectWizard.StartWizard();
        }
示例#30
0
 /// <summary>
 /// Constructs a view model.
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 public SelfUpdatingPage(ConnectWizard wizard) :
     base(wizard)
 {
 }
示例#31
0
 /// <summary>
 /// Constructs a wizard page.
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 public ConnectWizardStandardPage(ConnectWizard wizard) :
     base(wizard)
 {
 }
示例#32
0
 /// <summary>
 /// Constructs a settings wizard page.
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 public SettingsPage(ConnectWizard wizard) :
     base(wizard)
 {
 }
示例#33
0
        /// <inheritdoc/>
        public override void FromSettings(ConnectWizard wizard, Xml.InstanceSourceSettingsBase settings)
        {
            if (settings is Xml.LocalInstanceSourceSettings h_local)
            {
                // - Restore instance list.
                // - Restore connecting instance (optional).
                foreach (var h_instance in h_local.ConnectingInstanceList)
                {
                    var connecting_instance = InstanceList.FirstOrDefault(inst => inst.Base.AbsoluteUri == h_instance.Base.AbsoluteUri);
                    if (connecting_instance == null)
                    {
                        // The connecting instance was not found. Could be user entered, or removed from discovery file.
                        connecting_instance = new Instance(h_instance.Base);
                        connecting_instance.RequestAuthorization += wizard.Instance_RequestAuthorization;
                        connecting_instance.ForgetAuthorization  += wizard.Instance_ForgetAuthorization;
                    }
                    connecting_instance.Popularity = h_instance.Popularity;

                    // Restore connecting profiles (optionally).
                    ObservableCollection <Profile> profile_list = null;
                    try
                    {
                        switch (Properties.Settings.Default.ConnectingProfileSelectMode)
                        {
                        case 0:
                        case 2:
                            // This might trigger OAuth.
                            profile_list = connecting_instance.GetProfileList(connecting_instance, Window.Abort.Token);
                            break;
                        }
                    }
                    catch (OperationCanceledException) { throw; }
                    catch
                    {
                        // When profile list could not be obtained from the instance, instance settings should be forgotten to avoid issues next time.
                        connecting_instance.Forget();
                        continue;
                    }
                    switch (Properties.Settings.Default.ConnectingProfileSelectMode)
                    {
                    case 0:
                    {
                        // Restore only profiles user connected to before.
                        foreach (var h_profile in h_instance.ProfileList)
                        {
                            var profile = profile_list.FirstOrDefault(prof => prof.ID == h_profile.ID);
                            if (profile != null)
                            {
                                // Synchronise profile data.
                                h_profile.DisplayName = profile.DisplayName;
                                profile.Popularity    = h_profile.Popularity;
                            }
                            else
                            {
                                // The profile is gone missing. Create an unavailable profile placeholder.
                                profile = new Profile
                                {
                                    Instance    = connecting_instance,
                                    ID          = h_profile.ID,
                                    DisplayName = h_profile.DisplayName,
                                    Popularity  = h_profile.Popularity
                                };
                                profile.RequestAuthorization += (object sender_profile, RequestAuthorizationEventArgs e_profile) => connecting_instance.OnRequestAuthorization(connecting_instance, e_profile);
                            }

                            // Add to the list of connecting profiles.
                            if (ConnectingProfileList.FirstOrDefault(prof => prof.Equals(profile)) == null)
                            {
                                ConnectingProfileList.Add(profile);
                            }
                        }
                    }
                    break;

                    case 2:
                    {
                        // Add all available profiles to the connecting profile list.
                        // Restore popularity on the fly (or leave default to promote newly discovered profiles).
                        foreach (var profile in profile_list)
                        {
                            var h_profile = h_instance.ProfileList.FirstOrDefault(prof => prof.ID == profile.ID);
                            if (h_profile != null)
                            {
                                profile.Popularity = h_profile.Popularity;
                            }

                            ConnectingProfileList.Add(profile);
                        }
                    }
                    break;
                    }

                    var instance = ConnectingInstanceList.FirstOrDefault(inst => inst.Base.AbsoluteUri == connecting_instance.Base.AbsoluteUri);
                    if (instance == null)
                    {
                        ConnectingInstanceList.Add(connecting_instance);
                    }
                }
                ConnectingInstance = SelectConnectingInstance(h_local.ConnectingInstance);
            }
        }
 /// <summary>
 /// Constructs a panel
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 /// <param name="instance_source_type">Instance source type</param>
 public ConnectingInstanceAndProfileSelectPanel(ConnectWizard wizard, InstanceSourceType instance_source_type) :
     base(wizard, instance_source_type)
 {
 }
示例#35
0
 /// <summary>
 /// Constructs a wizard page.
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 public ConnectWizardPage(ConnectWizard wizard)
 {
     Wizard = wizard;
 }
示例#36
0
 /// <summary>
 /// Constructs an instance selection wizard page.
 /// </summary>
 /// <param name="wizard">The connecting wizard</param>
 public AuthenticatingInstanceSelectPage(ConnectWizard wizard) :
     base(wizard)
 {
 }