v1.0.0
Latest
2020.3+

Interface IMessagingService

IMessagingService allows users to send a message to other users.

Namespace: Unity.Services.Friends
Syntax
public interface IMessagingService

Methods

MessageAsync<T>(String, T)

Sends a message from the current user to the target user. To ease deserialization of sent message on the receiving client, the message must have an empty constructor. The maximum size of the message payload is 10 kilobytes.

Declaration
Task MessageAsync<T>(string targetUserId, T message)
    where T : new()
Parameters
TypeNameDescription
StringtargetUserId

The ID of the user to target with the message. Must be friends with the current user.

Tmessage

The message to send. It must be serializable (and deserializable) as JSON

Returns
TypeDescription
Task
Type Parameters
NameDescription
T
Exceptions
TypeCondition
InvalidOperationException

Represents an error that occurs when the service has not been initialized.

ArgumentException

Represents an error that occur when an argument is incorrectly set up.

FriendsServiceException

An exception containing the HttpClientResponse with headers, response code, and string of error.