Game ideas & features

Your next feature

Friends

Friends, requests and blocks for the selected project.

SDK developRequires a player session
Unity
Illustration of Friends
Your visible result

After timeout or conflict, refresh and reconcile the intent. Never automatically retry with a new revision.

Video coming later

This step does not have a video yet. The guide and MCP request are ready to use.

Friends

Prepare the same project

  1. Choose the same project in the dashboard as in your game configuration.

    Friends →
  2. No additional definition is needed for the first request. An empty result is valid until matching game data exists.

    Use two separate player sessions in the same project. Copy the other player’s exact UUID from User Management.

    Use an exact UUID or canonical H-code. Names and emails are not accepted.

    Inspect here; only the player’s own session can change relationships.

Build this feature

You can preview the guide. Running it requires an active project key. Prepare project

SDK installed, project configuration imported and player signed in.

This SDK example uses develop. Check whether the required APIs exist in your installed SDK.

Complete the Quickstart connection with the intended player. Call RunReviewedAction() from an explicit button or scene action. Opening the file alone sends no request.

C#
Assets/Scripts/FriendsDemo.cs
horizOn call
1using UnityEngine;
2using PM.horizOn.Cloud.Core;
3using PM.horizOn.Cloud.Manager;
4​
5// Existing SDK/project configuration and authenticated player session required.
6// Call RunReviewedAction explicitly after reviewing this example and its data.
7// After timeout or conflict, refresh and reconcile the intent. Never
8// automatically retry with a new revision.
9public sealed class FriendsDemo : MonoBehaviour
10{
11 public async void RunReviewedAction()
12 {
13 var sessionUser = UserManager.Instance.CurrentUser;
14 if (sessionUser == null || !sessionUser.IsValid()) return;
15 var userId = UserManager.Instance.CurrentUser.UserId;
16 var manager = FriendsManager.Instance;
17 var loaded = await manager.GetFriends(userId);
18 if (!loaded.IsSuccess) { Debug.LogWarning(loaded.ErrorCode); return; }
19 Debug.Log(loaded.Data.friendCode); // Public identifier, not a credential.
20 foreach (var friend in loaded.Data.friends)
21 Debug.Log(friend.display.name + ": " + (friend.lastActiveAt ?? "unknown"));
22​
23 // Invoke only after the player explicitly reviews this snapshot and chooses an action.
24 async System.Threading.Tasks.Task ApplyReviewed(string action, string targetUserId,
25 long expectedRevision, string requestId = null)
26 {
27 var result = action switch {
28 "request" => await manager.SendRequest(userId, targetUserId, expectedRevision),
29 "accept" => await manager.AcceptRequest(userId, targetUserId, expectedRevision, requestId),
30 "decline" => await manager.DeclineRequest(userId, targetUserId, expectedRevision, requestId),
31 "cancel" => await manager.CancelRequest(userId, targetUserId, expectedRevision, requestId),
32 "remove" => await manager.RemoveFriend(userId, targetUserId, expectedRevision),
33 "block" => await manager.BlockPlayer(userId, targetUserId, expectedRevision),
34 "unblock" => await manager.UnblockPlayer(userId, targetUserId, expectedRevision),
35 _ => throw new System.ArgumentException("Unknown action")
36 };
37 if (!result.IsSuccess) {
38 Debug.LogWarning(result.ErrorCode); // Timeout/409: reload and reconcile; do not repeat automatically.
39 return;
40 }
41 Debug.Log(result.Data.revision); // Replace the whole displayed snapshot.
42 }
43 // Accept/decline: original incoming requestId. Cancel: original outgoing requestId.
44 // Never replace expectedRevision on an uncertain retry. A new request is a new identity.
45 // FindPlayer(userId, exactUuidOrHCode) never searches names or emails.
46 // Last login is nullable, never an online flag. No hidden polling timer.
47 }
48}
Open the complete SDK sample ↗

Test your new feature.

After timeout or conflict, refresh and reconcile the intent. Never automatically retry with a new revision.

Choose the same project in the dashboard as in your game configuration.

Endpoints
  • GET/friends
  • GET/friends/find
  • POST/friends/request
  • POST/friends/accept
  • POST/friends/decline
  • POST/friends/cancel
  • POST/friends/remove
  • POST/friends/block
  • POST/friends/unblock
All endpoints in the API reference
Our suggestion for your next step

Give every round a high score.

Save the score after a round and show who's ahead. Keep using your connection and player session.