Interface IFriendsService
FriendsService is the managed service that let's user's interact with the Friends package's features
Inherited Members
Namespace: Unity.Services.Friends
Syntax
public interface IFriendsService : IMessagingService
Properties
Blocks
The list of the user's blocks.
Declaration
IReadOnlyList<Relationship> Blocks { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Relationship> |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
Friends
The list of the user's friends.
Declaration
IReadOnlyList<Relationship> Friends { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Relationship> |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
IncomingFriendRequests
The list of the user's incoming friend requests.
Declaration
IReadOnlyList<Relationship> IncomingFriendRequests { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Relationship> |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
OutgoingFriendRequests
The list of the user's outgoing friend requests.
Declaration
IReadOnlyList<Relationship> OutgoingFriendRequests { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Relationship> |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
Relationships
The full list of the user's relationships.
Declaration
IReadOnlyList<Relationship> Relationships { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Relationship> |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
Methods
AddBlockAsync(String)
Creates a block towards the targeted user.
Declaration
Task<Relationship> AddBlockAsync(string memberId)
Parameters
Type | Name | Description |
---|---|---|
String | memberId | The ID of the target user. |
Returns
Type | Description |
---|---|
Task<Relationship> | The block created |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
AddFriendAsync(String)
Creates a friend request, or automatically creates a friendship if the user already has an incoming friend request from the targeted user.
Declaration
Task<Relationship> AddFriendAsync(string memberId)
Parameters
Type | Name | Description |
---|---|---|
String | memberId | The ID of the target user. |
Returns
Type | Description |
---|---|
Task<Relationship> | The friendship created |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
AddFriendByNameAsync(String)
Creates a friend request, or automatically creates a friendship if the user already has an incoming friend request from the targeted user by their user name.
Declaration
Task<Relationship> AddFriendByNameAsync(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the target user |
Returns
Type | Description |
---|---|
Task<Relationship> | The friendship created |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
DeleteBlockAsync(String)
Deletes a block.
Declaration
Task DeleteBlockAsync(string memberId)
Parameters
Type | Name | Description |
---|---|---|
String | memberId | The ID of the user that will be unblocked. |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
RelationshipNotFoundException | Represents an error that occurs when a relationship is not found. |
DeleteFriendAsync(String)
Deletes a friend.
Declaration
Task DeleteFriendAsync(string memberId)
Parameters
Type | Name | Description |
---|---|---|
String | memberId | The ID of the friend to be deleted. |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
RelationshipNotFoundException | Represents an error that occurs when a relationship is not found. |
DeleteIncomingFriendRequestAsync(String)
Deletes an incoming friend request.
Declaration
Task DeleteIncomingFriendRequestAsync(string memberId)
Parameters
Type | Name | Description |
---|---|---|
String | memberId | The ID of the user that sent the friend request. |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
RelationshipNotFoundException | Represents an error that occurs when a relationship is not found. |
DeleteOutgoingFriendRequestAsync(String)
Deletes an outgoing friend request.
Declaration
Task DeleteOutgoingFriendRequestAsync(string memberId)
Parameters
Type | Name | Description |
---|---|---|
String | memberId | The ID of the user that a friend request was sent to. |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
RelationshipNotFoundException | Represents an error that occurs when a relationship is not found. |
DeleteRelationshipAsync(String)
Deletes a relationship.
Declaration
Task DeleteRelationshipAsync(string relationshipId)
Parameters
Type | Name | Description |
---|---|---|
String | relationshipId | The ID of the relationship to be deleted. |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
ForceRelationshipsRefreshAsync()
Forcefully refreshes the list of relationships in case they were not refreshed automatically by the service
Declaration
Task ForceRelationshipsRefreshAsync()
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
InitializeAsync(InitializeOptions)
Initialize the Friends service API. This must be called before using any other functionality of the Friends service. This can only be called when a user is signed in.
Declaration
Task InitializeAsync(InitializeOptions initializeOptions = null)
Parameters
Type | Name | Description |
---|---|---|
InitializeOptions | initializeOptions | Options to initialize the Friends service |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
SetPresenceActivityAsync<T>(T)
Sets the user's presence activity value.
Declaration
Task SetPresenceActivityAsync<T>(T activity)
where T : new()
Parameters
Type | Name | Description |
---|---|---|
T | activity | The activity value to be set for the user's presence. |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
SetPresenceAsync<T>(Availability, T)
Sets the presence for the user.
Declaration
Task SetPresenceAsync<T>(Availability availabilityOption, T activity)
where T : new()
Parameters
Type | Name | Description |
---|---|---|
Availability | availabilityOption | The type of availability to be set for the user's presence. |
T | activity | The activity value to be set for the user's presence. |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
SetPresenceAvailabilityAsync(Availability)
Sets the user's presence availability.
Declaration
Task SetPresenceAvailabilityAsync(Availability availabilityOption)
Parameters
Type | Name | Description |
---|---|---|
Availability | availabilityOption | The type of availability to be set for the user's presence. |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
ArgumentException | Represents an error that occurs when an argument is incorrectly setup. |
FriendsServiceException | An exception containing the HttpClientResponse with headers, response code, and string of error. |
InvalidOperationException | Represents an error that occurs when the service has not been initialized. |
Events
MessageReceived
Event called when a message is received.
Declaration
event Action<IMessageReceivedEvent> MessageReceived
Event Type
Type | Description |
---|---|
Action<IMessageReceivedEvent> |
PresenceUpdated
Event called when a friend's presence is updated.
Declaration
event Action<IPresenceUpdatedEvent> PresenceUpdated
Event Type
Type | Description |
---|---|
Action<IPresenceUpdatedEvent> |
RelationshipAdded
Event called when a relationship gets added.
Declaration
event Action<IRelationshipAddedEvent> RelationshipAdded
Event Type
Type | Description |
---|---|
Action<IRelationshipAddedEvent> |
RelationshipDeleted
Event called when a relationship gets deleted.
Declaration
event Action<IRelationshipDeletedEvent> RelationshipDeleted
Event Type
Type | Description |
---|---|
Action<IRelationshipDeletedEvent> |