示例#1
0
        //---------------------------------------------------------------------
        #endregion // DirectPlay Lobby Event Handlers

        /// <summary>
        /// Host or connect to a session based on the settings provided by the lobby
        /// </summary>
        public void LobbyLaunch()
        {
            // Create an object to retrieve the connection settings from the lobby client
            Lobby.ConnectionSettings settings;

            try
            {
                // Get settings
                settings      = m_LobbyApp.GetConnectionSettings(m_LobbyHandle);
                m_SessionName = settings.ApplicationDescriptionChanged.SessionName;

                // If host flag is set, this application should create a new session
                if (0 != (settings.Flags & Lobby.ConnectionSettingsFlags.Host))
                {
                    // Host a new session
                    m_Peer.Host(settings.ApplicationDescriptionChanged, // Application description
                                settings.GetDeviceAddresses());         // Local device addresses

                    // After the connection is complete, initialize a new
                    // DirectPlay voice server.
                    m_Connection = ConnectionType.Hosting;
                    InitDirectPlayVoice();
                }
                else
                {
                    // Connect to an existing session
                    m_Peer.Connect(settings.ApplicationDescriptionChanged, // Application description
                                   settings.HostAddress,                   // Host address
                                   settings.GetDeviceAddresses()[0],       // Local device address
                                   null,                                   // Async handle
                                   ConnectFlags.Sync);                     // Connect flags

                    // After the connection is complete, initialize a new
                    // DirectPlay voice client.
                    m_Connection = ConnectionType.Connected;
                    InitDirectPlayVoice();
                }
            }
            catch (Exception ex)
            {
                m_Form.ShowException(ex, null, true);
                m_Form.Dispose();
                return;
            }

            UpdateUI();
        }
示例#2
0
        /// <summary>
        /// Host or connect to a session based on the settings provided by the lobby
        /// </summary>
        public void LobbyLaunch()
        {
            // Create an object to retrieve the connection settings from the lobby client
            Lobby.ConnectionSettings settings;

            try
            {
                // Get settings
                settings    = myLobbyApp.GetConnectionSettings(myLobbyHandle);
                sessionName = settings.ApplicationDescriptionChanged.SessionName;

                // If host flag is set, this application should create a new session
                if (0 != (settings.Flags & Lobby.ConnectionSettingsFlags.Host))
                {
                    // Host a new session
                    myPeer.Host(settings.ApplicationDescriptionChanged, // Application description
                                settings.GetDeviceAddresses());         // Local device addresses

                    myConnection = ConnectionType.Hosting;
                }
                else
                {
                    // Connect to an existing session
                    myPeer.Connect(settings.ApplicationDescriptionChanged, // Application description
                                   settings.HostAddress,                   // Host address
                                   settings.GetDeviceAddresses()[0],       // Local device address
                                   null,                                   // Async handle
                                   ConnectFlags.Sync);                     // Connect flags

                    myConnection = ConnectionType.Connected;
                }
            }
            catch (Exception ex)
            {
                myForm.ShowException(ex, null, true);
                myForm.Dispose();
                return;
            }

            UpdateUI();
        }