Skip to main content
HyperX chat lets authenticated users join channels and exchange messages inside a project. The server stores channels, memberships, message order, acknowledgements, and reports. Operators can inspect and moderate chat from Console.

Create and Join a Channel

var channel = await player.CreateChatChannel(
    channelKey: "global",
    channelType: HyperX.ChatChannelType.Project,
    displayName: "Global",
    retentionDays: 90
);

await player.JoinChat(channel.Id);
Supported channel types are HyperX.ChatChannelType.Project, HyperX.ChatChannelType.Guild, HyperX.ChatChannelType.Party, HyperX.ChatChannelType.Direct, and HyperX.ChatChannelType.Announcement. You can still pass a string for custom values. Announcement channels are read-only for regular users.

Send and Read Messages

var sent = await player.SendChatMessage(
    channel.Id,
    "hello"
);

var messages = await player.ChatMessages(
    channel.Id,
    afterSequence: sent.Sequence - 1
);

await player.AcknowledgeChat(
    channel.Id,
    sent.Sequence
);
sequence is the increasing message number inside a channel. After reconnecting, pass the last processed sequence as afterSequence to catch up.

Unity Subscription

var subscription = player.SubscribeChat(
    channel.Id,
    message => Debug.Log(message.Body),
    error => Debug.LogWarning(error.Message),
    pollIntervalMilliseconds: 2000
);

// When the GameObject is destroyed
subscription.Dispose();
Subscribe only while the chat screen is open, and call Dispose when it closes. Subscriptions keep the last processed sequence and acknowledge after new messages are delivered to the callback. On transient failures the SDK enters reconnecting, applies bounded backoff up to 30 seconds, and resumes catch-up from the last sequence. If your access token expires, refresh the session with Core.Users.Refresh(refreshToken) and recreate the subscription with the new access token.

Reports and Moderation

await player.ReportChatMessage(
    channel.Id,
    messageId,
    reason: "spam"
);
If an operator mutes a user or hides a message, SDK calls may return structured errors.
try
{
    await player.SendChatMessage(channel.Id, "hello");
}
catch (HyperX.HyperXServerException ex)
    when (ex.ErrorCode == "CHAT_SENDER_MUTED")
{
    Debug.Log("The player is muted in chat.");
}