Last Updated: 9/22/2021, 7:52:24 AM

# Chat

# Overview

Chat is a service that allows players to send and receive messages to their friends or party members in real-time. This service includes notifications to inform users of messages being sent or received. The Chat service is divided into three basic features:

  1. Chat: Send Personal Chat allows players to message their friends. The sender will receive a notification when their message has been sent, and the recipient will receive a notification when they have a new message.
  2. Chat: Send Party Chat allows users to send a message to all of the players in their party. The party members will be notified when they have a new message from the sender.
  3. Load Personal Chat History involves retrieving a player’s chat history with another player. This action can be performed by sending an HTTP Request only if the player has permission to perform this action, i.e. the player hasn’t been blocked.

# How It Works

# Global Chat

By default, a player can join a global channel and start broadcasting messages to all other players in the game.

chat

# Permissions

Permissions are used to grant access to specific resources within our services. Make sure your account has the following permissions before you attempt to manage chat in the Admin Portal.

Usage Resource Action
Load Personal Chat History NAMESPACE:{namespace}:USER:{userId}:CHAT Read
Get Chat History NAMESPACE:{namespace}:USER:{userId}:CHAT Read
Load Personal Chat History based on Friend’s User ID Required valid user authorization Read

Permissions work slightly differently depending on whether they are assigned to IAM Clients or Roles assigned to users. For more information, read the Authentication and Authorization documentation.

# Implementing Chat using the SDK

Chat features are handled by the Lobby service. You must connect to the Lobby service before you can enable chat.

# Personal Chat

Players can communicate with other players using personal chat.

# Send a Personal Chat

A player can send a personal message to any other player, if they know their User ID.

# Receive a Personal Chat

Personal chats can be received by registering to the personal chat event.

# Party Chat

When a party has been formed, its members can use the chat feature to communicate with each other. Every message sent will be received by all of the party members.

# Send a Party Chat

The Lobby service will automatically direct a player’s messages to their own party, so the player doesn’t need to know their Party ID.

# Receive a Party Chat

A party chat can be received by registering to a party chat event.

# Global Chat

# Join a Default Channel

Players can join a default channel to chat with all other players currently logged into the game.

# Receive a Global Chat

Receiving a message from a global channel can be done by registering to a channel chat event using the following code:

# Managing Chat using the API

# Load Personal Chat History

You can query personal chat history in a namespace using the API. To do so, follow the steps below:

  1. Use the Load Personal Chat History: GET - /chat/namespaces/{namespace}/users/{userId}/friend/{friendId} endpoint.
  2. Input the Namespace where the chat belongs.
  3. Input the User ID that sends the chat.
  4. Input the Friend ID of the chat receiver.

Upon a successful request, the chat history will be retrieved. Here is the response example of the successful request:

# Get Chat History

You can query chat history in a namespace using the API. To do so, follow the steps below:

  1. Use the Admin Get Chat History: GET - /lobby/v1/admin/chat/namespaces/{namespace}/users/{userId}/friends/{friendId} endpoint.
  2. Input the Namespace where the chat belongs.
  3. Input the User ID that sends the chat.
  4. Input the Friend ID of the chat receiver.

Upon a successful request, the chat history will be retrieved. Here is the response example of the successful request:

# Load Personal Chat History based on Friend’s User ID

You can query personal chat history based on Friends User ID using the API. To do so, follow the steps below:

  1. Use the Load Personal Chat History: GET - /lobby/v1/public/chat/namespaces/{namespace}/users/me/friends/{friendId} endpoint.
  2. Input the Namespace where the chat belongs.
  3. Input the Friend ID of the chat receiver.

Upon a successful request, the personal chat history will be retrieved. Here is the response example of the successful request: