This page documents the hand-written lobby management methods on the Dota2 struct. These methods cover creating lobbies, leaving/creating lobbies atomically, managing team slots, and responding to invites. They complement the generated API methods and rely on the SOCache system to track lobby state.
For the underlying protocol message types (CSODOTALobby, CMsgPracticeLobbySetDetails, etc.), see Match Management Protocol.
| File | Responsibility |
|---|---|
client_lobby.go | Core lobby lifecycle: create, leave/create, clear team, invite response |
client_lobby_members.go | Inviting players to the current lobby |
client_lobby_slot.go | Joining a team slot, assigning bot difficulty to a slot |
Sources: client_lobby.go1-10 client_lobby_members.go1-6 client_lobby_slot.go1-6
| Method | File | GC Message Sent | Description |
|---|---|---|---|
CreateLobby | client_lobby.go | k_EMsgGCPracticeLobbyCreate | Fire-and-forget lobby creation |
LeaveCreateLobby | client_lobby.go | Multiple (context-driven) | Atomic leave-then-create with SOCache polling |
ClearTeamFromLobby | client_lobby.go | k_EMsgGCClearPracticeLobbyTeam | Clears all players from a team in the lobby |
RespondLobbyInvite | client_lobby.go | k_EMsgGCLobbyInviteResponse | Accepts or declines a lobby invite |
InviteLobbyMember | client_lobby_members.go | k_EMsgGCInviteToLobby | Sends an invite to a player by Steam ID |
JoinLobbyTeam | client_lobby_slot.go | k_EMsgGCPracticeLobbySetTeamSlot | Switches the client to a given team/slot |
SetLobbySlotBotDifficulty | client_lobby_slot.go | k_EMsgGCPracticeLobbySetTeamSlot | Assigns a bot with a given difficulty to a slot |
Sources: client_lobby.go12-86 client_lobby_members.go8-14 client_lobby_slot.go8-23
CreateLobbySends CMsgPracticeLobbyCreate to the GC using the fire-and-forget write path. The PassKey and LobbyDetails fields are taken from the supplied CMsgPracticeLobbySetDetails pointer client_lobby.go14-17 This method does not block or return an error; the resulting lobby state is observed via the SOCache Lobby container.
LeaveCreateLobbyThis is the most complex hand-written lobby method. It guarantees that after it returns, the client is in a freshly created lobby matching the supplied details. The logic is context-driven and SOCache-driven:
Lobby container from the SOCache via GetContainerForTypeID(uint32(cso.Lobby)) client_lobby.go22-25cacheCtr.Subscribe() client_lobby.go27-31wasInNoLobby is true — a new lobby has been created; return nil client_lobby.go39-42wasInNoLobby is false — leave the current lobby. If destroyOldLobby is true and the client is the leader, it calls DestroyLobby client_lobby.go45-51 It then calls AbandonLobby if the lobby state is not CSODOTALobby_UI client_lobby.go52-54 followed by LeaveLobby client_lobby.go55wasInNoLobby = true and call CreateLobby(details) client_lobby.go56-60ClearTeamFromLobbySends k_EMsgGCClearPracticeLobbyTeam with an empty CMsgFlipLobbyTeams body client_lobby.go73-77 This is used to clear the team from a practice lobby.
RespondLobbyInviteSends CMsgLobbyInviteResponse with the lobby_id and accept boolean. Uses EGCBaseMsg_k_EMsgGCLobbyInviteResponse (base GC message ID) client_lobby.go82-85
InviteLobbyMemberConverts a steamid.SteamId to uint64 and sends CMsgInviteToLobby with the steam_id field set. Uses EGCBaseMsg_k_EMsgGCInviteToLobby client_lobby_members.go11-13
JoinLobbyTeamSends CMsgPracticeLobbySetTeamSlot with team and slot set client_lobby_slot.go10-13 This is used to switch teams or slots within a lobby.
SetLobbySlotBotDifficultySends CMsgPracticeLobbySetTeamSlot with team, slot, and bot_difficulty all set client_lobby_slot.go18-22 Uses the same message type as JoinLobbyTeam; the presence of bot_difficulty signals a bot assignment to the GC.
Title: Lobby lifecycle state transitions driven by LeaveCreateLobby
Sources: client_lobby.go21-69
Title: Hand-written lobby methods and their GC protocol messages
Sources: client_lobby.go13-86 client_lobby_members.go9-14 client_lobby_slot.go9-23
Lobby state is not returned synchronously from most methods. The GC pushes the resulting CSODOTALobby shared object through the SOCache pipeline. Consumers must subscribe to the cso.Lobby container to observe the current lobby, its members, and state changes.
LeaveCreateLobby is the primary lobby method that reads from the SOCache directly via cacheCtr.GetOne() client_lobby.go35 and subscribes to change events client_lobby.go27 making it a self-contained state machine. All other methods are fire-and-forget (they call d.write(...) and return immediately).
| Symbol | Package | Role |
|---|---|---|
CMsgPracticeLobbySetDetails | protocol | Lobby configuration input to CreateLobby and LeaveCreateLobby |
CMsgPracticeLobbyCreate | protocol | Wire message wrapping CMsgPracticeLobbySetDetails |
CSODOTALobby | protocol | Shared object representing live lobby state in SOCache |
CSODOTALobby_UI | protocol | Enum value indicating the lobby is in the setup phase protocol/dota_gcmessages_common_lobby.pb.go134 |
DOTA_GC_TEAM | protocol | Enum for Radiant/Dire/Broadcaster/etc. used by slot methods |
DOTABotDifficulty | protocol | Enum for bot difficulty levels |
cso.Lobby | cso | Integer type ID for the CSODOTALobby shared object type |
Sources: client_lobby.go13-69 client_lobby_slot.go9-23 protocol/dota_gcmessages_common_lobby.pb.go131-142
Refresh this wiki