1extends Node
2
3# Existing configured SDK and authenticated player session required.
4# Invoke run_reviewed_action explicitly after reviewing this example.
5func run_reviewed_action() -> void:
6 if not Horizon.auth.isSignedIn():
7 return
8 var user_id: String = Horizon.auth.getCurrentUser().userId
9 var loaded: Dictionary = await Horizon.friends.getFriends(user_id)
10 if not loaded.success:
11 push_warning(loaded.errorCode)
12 return
13 print(loaded.data.friendCode) # Public identifier, not a credential.
14 for friend in loaded.data.friends:
15 print(friend.display.name, ": ", friend.lastActiveAt) # null means unknown, not offline.
16
17 # Examples for explicit player actions, never run these as an automatic sequence:
18 # var found = await Horizon.friends.findPlayer(user_id, exact_uuid_or_h_code)
19 # var r = await Horizon.friends.sendRequest(user_id, target_id, reviewed_revision)
20 # var r = await Horizon.friends.acceptRequest(user_id, target_id, reviewed_revision, original_request_id)
21 # var r = await Horizon.friends.declineRequest(user_id, target_id, reviewed_revision, original_request_id)
22 # var r = await Horizon.friends.cancelRequest(user_id, target_id, reviewed_revision, original_request_id)
23 # var r = await Horizon.friends.removeFriend(user_id, target_id, reviewed_revision)
24 # var r = await Horizon.friends.blockPlayer(user_id, target_id, reviewed_revision)
25 # var r = await Horizon.friends.unblockPlayer(user_id, target_id, reviewed_revision)
26 # Success: replace the entire snapshot with r.data. Do not patch one side locally.
27 # Timeout/REVISION_CONFLICT: refresh and reconcile; never silently substitute a new revision.
28 # Keep original incoming requestId for accept/decline, outgoing requestId for cancel.
29 # Inbox notices are hints; only the current snapshot authorizes a request action.
30 # Refresh explicitly on reconnect/metadata invalidation; no hidden polling timer.