Skip to content

Chat

This feature of the GOG GALAXY SDK allows GOG users to chat with each other independently from the in-game messaging. GOG chat is available on the website (after a user logs in), in the GOG GALAXY client application (when a user clicks a friend on the friends list) and in the overlay, and can be accessed directly by a game using the GOG GALAXY SDK.

Getting Chat Room Info

  1. First, call IChat::RequestChatRoomWithUser(), providing the ID of the user you want to start a chat with. (The ID is this user’s GalaxyID).
  2. The response comes to IChatRoomWithUserRetrieveListener. If the request was successful, the OnChatRoomWithUserRetrieveSuccess() method will return the ID of the entered chat room (chatRoomID), which is essential for the IChat methods.
  3. Having this chatRoomID, you can:

Sending Messages

  1. Request the chat room info as described in the steps #1 and #2.
  2. Call the IChat::SendChatRoomMessage() method, giving the chat room ID and the message text as its input parameters.
  3. If the message was sent successfully, the IChatRoomMessageSendListener::OnChatRoomMessageSendSuccess() callback method will be called, providing the ID of the chat room along with the internal index, the ID and the timestamp of the sent message, so you can track the sent messages (or indicate that sending is in progress).
  4. The recipients (members of the chat room) will receive a notification about an incoming message using the IChatRoomMessagesListener::OnChatRoomMessagesReceived() callback method, which provides the ID of the chat room, the number of messages received in this chat room and the length of the longest message, so you can allocate a buffer of an appropriate size.

Receiving Messages

You don’t have to call the IChat::RequestChatRoomWithUser() explicitly in order to receive new incoming messages. The notification about a new message comes to IChatRoomMessagesListener::OnChatRoomMessagesReceived() callback method, providing the ID of the chat room, the number of messages received in this chat room and the length of the longest message, so you can allocate a buffer of an appropriate size.

Within the OnChatRoomMessagesReceived() call, you can retrieve the subsequent messages with the IChat::GetChatRoomMessageByIndex() method, providing their index number and the size of the output buffer as input parameters. As a result, this method returns:

  • the global ID of the message,
  • the type of the message,
  • the message sender’s ID,
  • the time when the message was sent,
  • the contents of the message.

When the retrieval is completed, you can mark this chat room as read with the IChat::MarkChatRoomAsRead() method.

Fetching Historical Messages

  1. Request the chat room info as described in the steps #1 and #2.
  2. Call the IChat::RequestChatRoomMessages() method in order to retrieve:
    • messages older than the one defined by its ID in the referenceMessageID parameter, or
    • a specific number of latest messages defined by the limit parameter (when the referenceMessageID parameter is left empty).
  3. The response comes to IChatRoomMessagesRetrieveListener. If the operation was successful, the OnChatRoomMessagesRetrieveSuccess() callback method will provide the number of messages received along with the length of the longest message, so you can allocate a buffer of an appropriate size.
  4. Now you can retrieve the subsequent messages with the IChat::GetChatRoomMessageByIndex() method, providing their index number and the size of the output buffer as input parameters. As a result, this method returns:
    • the global ID of the message,
    • the type of the message,
    • the message sender’s ID,
    • the time when the message was sent,
    • the contents of the message.
  5. When the retrieval is completed, you can mark this chat room as read with the IChat::MarkChatRoomAsRead() method.
Back to top