Skip to main content

Real-Time Player Messaging (QuickChats)

The Skillz Java example client and server for real-time games includes functionality for implementing in-game messaging. At Skillz, we refer to these messages as QuickChats that typically take the form of short messages or emojis. Players can use this feature to send messages to their opponents while playing and increase social engagement with your game.

Skillz offers a pack of QuickChats that are used in some Skillz-powered games. Typically, real-time games have a button that can be used to access a player’s QuickChat options. When the player selects a QuickChat to send, it will briefly appear by that player’s avatar and be shown to both players. For a good example of QuickChats, please reference Diamond Strike’s (App Store link here) real-time game mode.

Match Starting

Implementation Guidelines​

In the code block below, you can see how the Example Sync Client handles incoming Chat messages. The message.ChatId value is pulled and passed to the current instance of the ChatManager. This class holds the logic for displaying chat images to the player. You can map the ChatId to the emoji image, and display that image to the player.

// Unity C# Client Code
private void on(Chat message)
{
Debug.Log("Chat message received!");
ChatManager.Instance.ShowPlayerChat(message.ChatId, false);
}

In terms of sending the chat message, you can call the following logic in Unity when one of the chat icons/emojis is pressed. First call the function in SyncGameController that sends the actual Chat Message. Then disable the Chat Button and display to the current player the chat they’ve just sent.

// Unity C# Client Code
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log(this.gameObject.name + " was selected, sending chat");
SyncGameController.Instance.SendChatForId(chatId);
ChatManager.Instance.HandleChatCooldown();
ChatManager.Instance.ShowPlayerChat(chatId, true);
}

On the server side, you can handle incoming messages like so, passing them directly to the other player.

// Java/Groovy Server Code
def validate(messages.Chat message) {
if (player.isPaused()) {
return false
}
true
}
def on(messages.Chat message) {
player.passthrough message
}

As for configuring chats and their images in the Unity Editor, take a look at the ChatContainer object shown below. The ChatManager script contains a list of Sprites that correspond to a list of Chat game objects. Each Chat Gameobject has a ChatObject script on it. For example, see the expanded Chat0 object in the hierarchy below; this object contains a ChatImage underneath it, which is referenced in the ChatObject script. This ChatObject script is where the ID of the Chat is set. The Sprite is managed by the ChatManager script, so you only need to set it once per Chat in the ChatSprites list. The Chat0...7 objects are normally hidden and are toggled active in the Unity scene when the user clicks on the UI button labeled “Chat” (See GIF below). Tapping on one of the now-visible Chat objects will run the OnPointerDown function shown above, sending the Chat message to the server, showing the emoji locally, and finally hiding the list of available Chats.

Example Example

As you can see, this functionality is fairly straight-forward to set up and only requires a few lines of code. While this is a relatively simple feature, it adds a valuable layer of social interaction to real-time game modes that can lead significantly higher engagement and retention.

More detailed steps for implementing this feature are linked here in the git-hub repo the example server and client. If you have any questions about this feature or anything related to your Skillz integration, please reach out to integrations@skillz.com.

QuickChat Assets​

There are two sets of QuickChats assets in the pack offered by Skillz - a collection of emojis and a collection of text messages. In deciding which QuickChats to offer, it is best practice to provide a mix of emotional responses (excited, sad, angry, congratulatory etc.) and be sure that the QuickChat options do not significantly block the game board. The access point to open up the QuickChat options should be clearly defined and accessible.

Download​

The Skillz QuickChat assets are shown below and can be accessed in the server/client example git repo here.

Match Starting