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

# PFLobbyServerLeaveAsServer

> PFLobbyServerLeaveAsServer reference for having a game_server leave a client-owned PlayFab lobby it previously joined via the PlayFab Multiplayer C++ SDK.

Requests that the server leave the client-owned lobby it's currently in.

## Syntax

```cpp theme={null}
HRESULT PFLobbyServerLeaveAsServer(  
    PFLobbyHandle lobby,  
    void* asyncContext  
)  
```

### Parameters

**`lobby`**   PFLobbyHandle

The handle of 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.

### 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()](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayergeterrormessage.md).

## Remarks

To use this feature, you must define PFMULTIPLAYER\_INCLUDE\_SERVER\_APIS before including PFLobby.h. \
\
&#x20;This method queues an asynchronous operation to exit the client-owned lobby. On completion, a [PFLobbyServerLeaveLobbyAsServerCompletedStateChange](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyserverleavelobbyasservercompletedstatechange.md) is provided indicating that the operation completed.   \
\
&#x20;This operation is restricted to client-owned lobbies that are using connections.   \
\
&#x20;Any server-owned data previously added to the lobby is NOT automatically deleted when the server leaves the lobby. If there's a desire to also delete the serverData, it should be explicitly done by calling [PFLobbyServerPostUpdateAsServer()](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbyserverpostupdateasserver.md) before leaving the lobby.

## Requirements

**Header:** PFLobby.h

## See also

[PFLobby members](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/pflobby_members.md)


## Related topics

- [PlayFab Multiplayer C++ SDK Release Notes](https://docs.xbox.com/services/playfab/multiplayer/lobby/lobby-matchmaking-sdks/lobby-and-matchmaking-release-notes.md)
- [PFMultiplayer C/C++ API overview - PFLobby.h](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/pflobby_members.md)
- [PFLobbyStateChangeType](https://docs.xbox.com/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/enums/pflobbystatechangetype.md)
- [Leave Lobby As Server](https://docs.xbox.com/services/playfab/api-references/rest/multiplayer/lobby/leave-lobby-as-server.md)
- [Lobby.LeaveAsServer](https://docs.xbox.com/services/playfab/multiplayer/lobby/unity-multiplayer-api-reference/PlayFab.Multiplayer/Lobby/LeaveAsServer.md)
