IFriendManager API
Scripts/Abstractions/IFriendManager.cs
The IFriendManager interface defines all friend management operations. FriendManager is the primary implementation, but this interface allows for custom implementations if needed.
Properties
| Property | Type | Description |
|---|---|---|
CurrentUserId | string | The ID of the logged-in user |
Friends | IReadOnlyList<Friend> | Current friends list |
PendingRequests | IReadOnlyList<FriendRequest> | Pending friend requests |
BlockedUsers | IReadOnlyList<BlockEntry> | Blocked users list |
BackendType | NetworkBackendType | Current network backend |
IsUsingNativeImplementation | bool | Native vs custom server |
Events
| Event | Signature | Description |
|---|---|---|
OnFriendsListUpdated | Action<IReadOnlyList<Friend>> | Fires when friend list changes |
OnFriendRequestReceived | Action<FriendRequest> | New incoming request |
OnFriendRequestAccepted | Action<Friend> | Request was accepted |
OnFriendRequestRejected | Action<string> | Request rejected (userId) |
OnFriendRequestCancelled | Action<FriendRequest> | Request was cancelled |
OnFriendStatusChanged | Action<Friend> | Friend's status changed |
OnFriendAdded | Action<Friend> | New friend added |
OnFriendRemoved | Action<Friend> | Friend removed |
OnUserBlocked | Action<BlockEntry> | User blocked |
OnUserUnblocked | Action<string> | User unblocked (userId) |
OnInvitationReceived | Action<FriendInvitation> | Invitation received |
OnPendingRequestsRefreshed | Action<IReadOnlyList<FriendRequest>> | Requests list updated |
Methods
Friend Operations
| Method | Description |
|---|---|
RefreshFriendList() | Manually refresh friend list from server |
SendFriendRequest(userId, callback) | Send friend request to user |
AddFriend(userId, callback) | Directly add friend (if backend allows) |
AcceptFriendRequest(requestId, callback) | Accept a pending request |
RejectFriendRequest(requestId, callback) | Reject a pending request |
CancelFriendRequest(requestId, callback) | Cancel your outgoing request |
RemoveFriend(userId, callback) | Remove a friend |
Block Operations
| Method | Description |
|---|---|
BlockUser(userId, callback) | Block a user |
UnblockUser(userId, callback) | Unblock a user |
RefreshBlockedUsers() | Refresh block list |
Invitation Operations
| Method | Description |
|---|---|
InviteFriend(userId, message, customData, callback) | Send game invitation |
AcceptInvitation(invitationId, callback) | Accept invitation |
DeclineInvitation(invitationId, callback) | Decline invitation |
RefreshInvitations() | Refresh invitations list |
Callback Format
All methods with callbacks use the same format:
Action<bool success, string errorMessage>
Example:
friendManager.SendFriendRequest("user123", (success, error) => {
if (success) {
Debug.Log("Request sent!");
} else {
Debug.LogError($"Error: {error}");
}
});