> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PFMultiplayerJoinLobbyAsServer

> PFMultiplayerJoinLobbyAsServer reference for joining a client-owned PlayFab lobby as a game_server entity through the PlayFab Multiplayer C++ SDK lobby APIs.

Join a client-owned lobby as a server.

## Syntax

```cpp theme={null}
HRESULT PFMultiplayerJoinLobbyAsServer(  
    PFMultiplayerHandle handle,  
    const PFEntityKey* server,  
    const char* connectionString,  
    const PFLobbyServerJoinConfiguration* configuration,  
    void* asyncContext,  
    PFLobbyHandle* lobby  
)  
```

### Parameters

**`handle`**   PFMultiplayerHandle

The handle of the PFMultiplayer API instance.

**`server`**   [PFEntityKey\*](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfentitykey_clientsdk)

The PlayFab Entity Key of the server joining the lobby. Its entity type must be "game\_server".

**`connectionString`**   char\*\
*is null-terminated*

The connection string used by the server to join the lobby.

**`configuration`**   [PFLobbyServerJoinConfiguration\*](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyserverjoinconfiguration)

The initial server-owned data to be stored when joining the lobby.

**`asyncContext`**   void\*\
*optional*

An optional, app-defined, pointer-sized context value that can be used to associate the completion state change with this call.

**`lobby`**   PFLobbyHandle\*\
*optional, library-allocated output*

The optional, output lobby object, which can be used to queue operations for immediate execution of this operation completes.

### Return value

Type: HRESULT

`S_OK` if the call succeeded or an error code otherwise. The human-readable form of the error code can be retrieved via [PFMultiplayerGetErrorMessage()](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayergeterrormessage).

## Remarks

To use this feature, you must define PFMULTIPLAYER\_INCLUDE\_SERVER\_APIS before including PFLobby.h. <br /><br /> This is an asynchronous operation. Completion of this method's execution isn't necessarily completion of the operation.   <br /><br /> Upon successful completion, the title is provided a [PFLobbyUpdatedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyupdatedstatechange) with the [PFLobbyUpdatedStateChange::serverUpdate](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyupdatedstatechange) member appropriately populated, and a [PFLobbyJoinLobbyAsServerCompletedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyjoinlobbyasservercompletedstatechange) with the [PFLobbyJoinLobbyAsServerCompletedStateChange::result](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyjoinlobbyasservercompletedstatechange) field set to `S_OK`.   <br /><br /> Upon a failed completion, the title is provided a [PFLobbyJoinLobbyAsServerCompletedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyjoinlobbyasservercompletedstatechange) with the [PFLobbyJoinLobbyAsServerCompletedStateChange::result](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyjoinlobbyasservercompletedstatechange) field set to a failure.   <br /><br /> This operation is restricted to client-owned lobbies that are using connections.

## Requirements

**Header:** PFLobby.h

## See also

[PFLobby members](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/pflobby_members)


## Related topics

- [PFLobbyJoinLobbyAsServerCompletedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyjoinlobbyasservercompletedstatechange.md)
- [PlayFab Multiplayer C++ SDK Release Notes](/services/playfab/multiplayer/lobby/lobby-matchmaking-sdks/lobby-and-matchmaking-release-notes.md)
- [PFLobbyGetLobbyId](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbygetlobbyid.md)
- [Lobby ownership](/services/playfab/multiplayer/lobby/owner-requirements-and-privileges.md)
- [PFLobbyGetServerConnectionStatus](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbygetserverconnectionstatus.md)
