Skip to content

Friends

The GOG GALAXY SDK allows you to download the list of your friends and get detailed information about them.

Important

After the user is logged in, the GOG GALAXY SDK automatically requests the friends list using the IFriends::RequestFriendList() method, and then retrieves user information for each member on the list using the IFriends::RequestUserInformation() method, so there is no need to request it explicitly with the steps outlined below. Moreover, the SDK receives broker notifications about any changes (addition, removal) to the friends list, keeping it up to date.

That said, the only thing developers should care about is iterating over the list with the help of the IFriends::GetFriendCount() and IFriends::GetFriendByIndex() methods. The following list of actions is here for your reference only to show how the things work.

  1. First, call IFriends::RequestFriendList().
  2. After the friends list is retrieved, you can browse it by calling:
  3. The request for a friends list automatically calls IFriends::RequestUserInformation().

    Note

    This call is performed automatically for friends (after requesting the list of friends) and fellow lobby members (after entering a lobby or getting a notification about some other user joining it), therefore in many cases you don’t need to call it manually. You should just wait for the appropriate callback to come to the IPersonaDataChangedListener.

  4. Responses to IFriends::RequestUserInformation() come both to the IPersonaDataChangedListener and to the IUserInformationRetrieveListener. Also, user’s avatars are downloaded, taking into account both the avatarCriteria argument given in RequestUserInformation() and the defaultAvatarCriteria value set by calling SetDefaultAvatarCriteria() (available options of avatar types are listed in the API documentation).

  5. After a user information is retrieved, you can read it by calling IFriends::GetFriendPersonaName() (not thread-safe) or IFriends::GetFriendPersonaNameCopy(). A user’s avatar can be obtained with IFriends::GetFriendAvatarUrl() (not thread-safe) or IFriends::GetFriendAvatarUrlCopy().

Inviting Friends

It is possible to invite your friends to play together by calling IFriends::ShowOverlayInviteDialog(). This method requires the connectionString argument, which will allow other users to join your game. Typically, the connectionString looks like this:

-connect-lobby-<id>

As a result of this call, a game invitation dialog is displayed and you can invite users to your game.

If an invited user accepts the invitation, the connectionString is added to the command-line parameters for launching the game. In case the game is already running, the connectionString comes to the IGameInvitationReceivedListener or to the IGameJoinRequestedListener, if the invite was accepted by the user on the overlay.

Important

Before you can use this call, the GOG GALAXY Overlay must be enabled in the GOG GALAXY client (it is on by default, but can be changed by the user), and then successfully injected into the game. To check whether the overlay is initialized, either call IUtils::GetOverlayState() or wait for the IOverlayInitializationStateChangeListener::OnOverlayStateChanged() callback.

RichPresence

The GOG GALAXY SDK allows you to set the RichPresence status, metadata and connect keys:

  • status key will be visible to your friends in the chat and friends list of the GOG GALAXY client,
  • connect key will be visible to your friends as JOIN button, which works exactly the same way as if a player received the game invitation sent with the IFriends::SendInvitation() method,
  • metadata key will not be publicly visible, but accessible to other components of a game; for example, this key could contain player’s coordinates on a map, which then could be used to display player’s position on a mini-map on-screen.

RichPresence information can be requested with the RequestRichPresence method. Responses come both to the IRichPresenceListener and the IRichPresenceRetrieveListener. In order to retrieve this information, use the GetRichPresence (not thread-safe) or the GetRichPresencemethods.