API Reference of GS2-Chat SDK for Game Engine
Model
EzRoom
Room
A room represents the area within which chat messages can be delivered. GS2-Chat rooms do not have the concept of participation. Therefore, you do not need to be a member of a room to receive messages, as long as you know the name of the room.
If you wish to limit the number of game players who can view the messages in a room, there are two options. The first is to set a password for the room. Second, you can whitelist the room and limit the game players by setting their user IDs in the whitelist.
Note that if you set a password, even the game administrator will not be able to retrieve messages without knowing the password.
This is because this may fall under the secret of communication
stipulated in the Constitution of Japan.
If you subscribe to a room, you can receive GS2-Gateway push notifications when new messages are sent to the room. By using this notification function, you will be able to know if there are any new messages without polling the room.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | UUID | ~ 128 chars | Room Name |
metadata | string | ~ 1024 chars | metadata |
EzMessage
Message
Messages are data posted to a room.
It has a field called category, which allows classification of messages. For example, a category of 0 is interpreted as a normal text message, while a category of If 1, the client can be run to process it as a stamp (sticker).
Posted messages are automatically deleted one hour after submission. This time cannot be changed.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | UUID | ~ 36 chars | Message name |
roomName | string | ✓ | UUID | ~ 128 chars | Room Name |
userId | string | ✓ | ~ 128 chars | User Id | |
category | int | ✓ | 0 | ~ 2147483645 | Type number when you want to classify message types. |
metadata | string | ✓ | ~ 1024 chars | metadata | |
createdAt | long | ✓ | Now | Datetime of creation (Unix time unit:milliseconds) |
EzSubscribe
Subscribe
By subscribing to a room, you will be instantly informed of new messages for that room. When subscribing, you can specify the category of the message. This feature can be used to subscribe only to messages that are of high importance to you.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
userId | string | ✓ | ~ 128 chars | User Id | |
roomName | string | ✓ | ~ 128 chars | Room name to subscribe to | |
notificationTypes | List<EzNotificationType> | [] | ~ 100 items | Category list to receive notifications of new messages |
EzNotificationType
Notification Type
Setting categories for receiving new message notifications
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
category | int | ✓ | 0 | ~ 2147483646 | Categories for which you receive new message notifications |
enableTransferMobilePushNotification | bool | ✓ | false | Transfer to mobile push notifications when you were offline? |
Methods
createRoom
Creating a Room
Fails if the namespace settings do not allow game players to create rooms. If a password is set for a room, the player will not be able to speak unless the password matches when he/she speaks.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
name | string | UUID | ~ 128 chars | Room Name | |
accessToken | string | ~ 128 chars | Owner User ID | ||
metadata | string | ~ 1024 chars | metadata | ||
password | string | ~ 128 chars | Password required to access the room | ||
whiteListUserIds | List<string> | [] | ~ 1000 items | List of user IDs with access to the room |
Result
Type | Description | |
---|---|---|
item | EzRoom | Room created |
Error
Special exceptions are defined in this API. GS2-SDK for GameEngine provides specialized exceptions derived from general exceptions to facilitate handling of errors that may need to be handled in games. Please refer to the documentation here for more information on common error types and handling methods.
Type | Base Type | Description |
---|---|---|
NoAccessPrivilegesException | BadRequestException | The whitelist configured for the room does not contain any currently logged in user. |
Implementation Example
try {
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var result = await domain.CreateRoomAsync(
name: "room-0001",
metadata: null,
password: null,
whiteListUserIds: null
);
var item = await result.ModelAsync();
} catch(Gs2.Gs2Chat.Exception.NoAccessPrivileges e) {
// The whitelist configured for the room does not contain any currently logged in user.
}
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var future = domain.CreateRoomFuture(
name: "room-0001",
metadata: null,
password: null,
whiteListUserIds: null
);
yield return future;
if (future.Error != null)
{
if (future.Error is Gs2.Gs2Chat.Exception.NoAccessPrivilegesException)
{
// The whitelist configured for the room does not contain any currently logged in user.
}
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
);
const auto Future = Domain->CreateRoom(
"room-0001" // name
// metadata
// password
// whiteListUserIds
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
auto e = Future->GetTask().Error();
if (e->IsChildOf(Gs2::Chat::Error::FNoAccessPrivilegesError::Class))
{
// The whitelist configured for the room does not contain any currently logged in user.
}
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (Future2->GetTask().IsError())
{
return Future2->GetTask().Error();
}
const auto Result = Future2->GetTask().Result();
deleteRoom
Deleting a Room
This can only be performed on rooms that player has created.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
roomName | string | ✓ | UUID | ~ 128 chars | Room Name |
accessToken | string | ~ 128 chars | Owner User ID |
Result
Type | Description | |
---|---|---|
item | EzRoom | Deleted Rooms |
Error
Special exceptions are defined in this API. GS2-SDK for GameEngine provides specialized exceptions derived from general exceptions to facilitate handling of errors that may need to be handled in games. Please refer to the documentation here for more information on common error types and handling methods.
Type | Base Type | Description |
---|---|---|
NoAccessPrivilegesException | BadRequestException | The whitelist configured for the room does not contain any currently logged in user. |
Implementation Example
try {
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
var result = await domain.DeleteRoomAsync(
);
} catch(Gs2.Gs2Chat.Exception.NoAccessPrivileges e) {
// The whitelist configured for the room does not contain any currently logged in user.
}
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
var future = domain.DeleteRoomFuture(
);
yield return future;
if (future.Error != null)
{
if (future.Error is Gs2.Gs2Chat.Exception.NoAccessPrivilegesException)
{
// The whitelist configured for the room does not contain any currently logged in user.
}
onError.Invoke(future.Error, null);
yield break;
}
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Room(
"room-0001", // roomName
nullptr // password
);
const auto Future = Domain->DeleteRoom(
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
auto e = Future->GetTask().Error();
if (e->IsChildOf(Gs2::Chat::Error::FNoAccessPrivilegesError::Class))
{
// The whitelist configured for the room does not contain any currently logged in user.
}
return false;
}
const auto Result = Future->GetTask().Result();
getRoom
Get room information
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
roomName | string | ✓ | UUID | ~ 128 chars | Room Name |
Result
Type | Description | |
---|---|---|
item | EzRoom | Room |
Implementation Example
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).User(
userId: null
).Room(
roomName: "room-0001",
password: null
);
var item = await domain.ModelAsync();
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).User(
userId: null
).Room(
roomName: "room-0001",
password: null
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->User(
nullptr // userId
)->Room(
"room-0001", // roomName
nullptr // password
);
const auto Future = Domain->Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).User(
userId: null
).Room(
roomName: "room-0001",
password: null
);
// Start event handling
var callbackId = domain.Subscribe(
value => {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
domain.Unsubscribe(callbackId);
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).User(
userId: null
).Room(
roomName: "room-0001",
password: null
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->User(
nullptr // userId
)->Room(
"room-0001", // roomName
nullptr // password
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Chat::Model::FRoom> value) {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
Domain->Unsubscribe(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
listLatestMessages
Get list of latest messages in a room
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
roomName | string | ✓ | ~ 128 chars | Room Name | |
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
password | string | ~ 128 chars | Password required to receive messages |
Result
Type | Description | |
---|---|---|
items | List<EzMessage> | List of Message |
Error
Special exceptions are defined in this API. GS2-SDK for GameEngine provides specialized exceptions derived from general exceptions to facilitate handling of errors that may need to be handled in games. Please refer to the documentation here for more information on common error types and handling methods.
Type | Base Type | Description |
---|---|---|
NoAccessPrivilegesException | BadRequestException | The whitelist configured for the room does not contain any currently logged in user. |
PasswordRequiredException | BadRequestException | A password must be set to access the room. |
PasswordIncorrectException | BadRequestException | The password set for the room does not match the password specified. |
Implementation Example
try {
var domain = gs2.Chat.Namespace(
namespaceName: "$namespace1.name"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
var items = await domain.LatestMessagesAsync(
).ToListAsync();
} catch(Gs2.Gs2Chat.Exception.NoAccessPrivileges e) {
// The whitelist configured for the room does not contain any currently logged in user.
} catch(Gs2.Gs2Chat.Exception.PasswordRequired e) {
// A password must be set to access the room.
} catch(Gs2.Gs2Chat.Exception.PasswordIncorrect e) {
// The password set for the room does not match the password specified.
}
var domain = gs2.Chat.Namespace(
namespaceName: "$namespace1.name"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
var it = domain.LatestMessages(
);
List<EzMessage> items = new List<EzMessage>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Chat->Namespace(
"$namespace1.name" // namespaceName
)->Me(
GameSession
)->Room(
"room-0001", // roomName
nullptr // password
);
const auto It = Domain->LatestMessages(
);
TArray<Gs2::UE5::Chat::Model::FEzMessagePtr> Result;
for (auto Item : *It)
{
if (Item.IsError())
{
return false;
}
Result.Add(Item.Current());
}
listMessages
Get list of messages in a room
Messages posted after the time of startAt can be retrieved. Messages matching startAt exactly are also included.
Messages are retrieved in order of oldest to newest post.
Messages can be traced back up to the past hour.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
roomName | string | ✓ | ~ 128 chars | Room Name | |
startAt | long | ✓ | Difference from current time(-1 hours) | Time to start retrieving messages | |
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
password | string | ~ 128 chars | Password required to receive messages |
Result
Type | Description | |
---|---|---|
items | List<EzMessage> | List of Message |
Error
Special exceptions are defined in this API. GS2-SDK for GameEngine provides specialized exceptions derived from general exceptions to facilitate handling of errors that may need to be handled in games. Please refer to the documentation here for more information on common error types and handling methods.
Type | Base Type | Description |
---|---|---|
NoAccessPrivilegesException | BadRequestException | The whitelist configured for the room does not contain any currently logged in user. |
PasswordRequiredException | BadRequestException | A password must be set to access the room. |
PasswordIncorrectException | BadRequestException | The password set for the room does not match the password specified. |
Implementation Example
try {
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
var items = await domain.MessagesAsync(
).ToListAsync();
} catch(Gs2.Gs2Chat.Exception.NoAccessPrivileges e) {
// The whitelist configured for the room does not contain any currently logged in user.
} catch(Gs2.Gs2Chat.Exception.PasswordRequired e) {
// A password must be set to access the room.
} catch(Gs2.Gs2Chat.Exception.PasswordIncorrect e) {
// The password set for the room does not match the password specified.
}
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
var it = domain.Messages(
);
List<EzMessage> items = new List<EzMessage>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Room(
"room-0001", // roomName
nullptr // password
);
const auto It = Domain->Messages(
);
TArray<Gs2::UE5::Chat::Model::FEzMessagePtr> Result;
for (auto Item : *It)
{
if (Item.IsError())
{
return false;
}
Result.Add(Item.Current());
}
Value change event handling
try {
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
// Start event handling
var callbackId = domain.SubscribeMessages(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeMessages(callbackId);
} catch(Gs2.Gs2Chat.Exception.NoAccessPrivileges e) {
// The whitelist configured for the room does not contain any currently logged in user.
} catch(Gs2.Gs2Chat.Exception.PasswordRequired e) {
// A password must be set to access the room.
} catch(Gs2.Gs2Chat.Exception.PasswordIncorrect e) {
// The password set for the room does not match the password specified.
}
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
var it = domain.Messages(
);
List<EzMessage> items = new List<EzMessage>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Room(
"room-0001", // roomName
nullptr // password
);
// Start event handling
const auto CallbackId = Domain->SubscribeMessages(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeMessages(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
post
Post a message.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
roomName | string | ✓ | ~ 128 chars | Room Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
category | int | ✓ | 0 | ~ 2147483645 | Type number when you want to classify message types. |
metadata | string | ✓ | ~ 1024 chars | metadata | |
password | string | ~ 128 chars | Password |
Result
Type | Description | |
---|---|---|
item | EzMessage | Posted message |
Error
Special exceptions are defined in this API. GS2-SDK for GameEngine provides specialized exceptions derived from general exceptions to facilitate handling of errors that may need to be handled in games. Please refer to the documentation here for more information on common error types and handling methods.
Type | Base Type | Description |
---|---|---|
NoAccessPrivilegesException | BadRequestException | The whitelist configured for the room does not contain any currently logged in user. |
PasswordRequiredException | BadRequestException | A password must be set to access the room. |
PasswordIncorrectException | BadRequestException | The password set for the room does not match the password specified. |
Implementation Example
try {
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
var result = await domain.PostAsync(
metadata: "MESSAGE_0001",
category: null
);
var item = await result.ModelAsync();
} catch(Gs2.Gs2Chat.Exception.NoAccessPrivileges e) {
// The whitelist configured for the room does not contain any currently logged in user.
} catch(Gs2.Gs2Chat.Exception.PasswordRequired e) {
// A password must be set to access the room.
} catch(Gs2.Gs2Chat.Exception.PasswordIncorrect e) {
// The password set for the room does not match the password specified.
}
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Room(
roomName: "room-0001",
password: null
);
var future = domain.PostFuture(
metadata: "MESSAGE_0001",
category: null
);
yield return future;
if (future.Error != null)
{
if (future.Error is Gs2.Gs2Chat.Exception.NoAccessPrivilegesException)
{
// The whitelist configured for the room does not contain any currently logged in user.
}
if (future.Error is Gs2.Gs2Chat.Exception.PasswordRequiredException)
{
// A password must be set to access the room.
}
if (future.Error is Gs2.Gs2Chat.Exception.PasswordIncorrectException)
{
// The password set for the room does not match the password specified.
}
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Room(
"room-0001", // roomName
nullptr // password
);
const auto Future = Domain->Post(
"MESSAGE_0001" // metadata
// category
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
auto e = Future->GetTask().Error();
if (e->IsChildOf(Gs2::Chat::Error::FNoAccessPrivilegesError::Class))
{
// The whitelist configured for the room does not contain any currently logged in user.
}
if (e->IsChildOf(Gs2::Chat::Error::FPasswordRequiredError::Class))
{
// A password must be set to access the room.
}
if (e->IsChildOf(Gs2::Chat::Error::FPasswordIncorrectError::Class))
{
// The password set for the room does not match the password specified.
}
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (Future2->GetTask().IsError())
{
return Future2->GetTask().Error();
}
const auto Result = Future2->GetTask().Result();
listSubscribeRooms
Get list of rooms to which you are subscribed
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | ||
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
Result
Type | Description | |
---|---|---|
items | List<EzSubscribe> | List of Subscribe |
nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var items = await domain.SubscribesAsync(
).ToListAsync();
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Subscribes(
);
List<EzSubscribe> items = new List<EzSubscribe>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
);
const auto It = Domain->Subscribes(
);
TArray<Gs2::UE5::Chat::Model::FEzSubscribePtr> Result;
for (auto Item : *It)
{
if (Item.IsError())
{
return false;
}
Result.Add(Item.Current());
}
Value change event handling
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
// Start event handling
var callbackId = domain.SubscribeSubscribes(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeSubscribes(callbackId);
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Subscribes(
);
List<EzSubscribe> items = new List<EzSubscribe>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
);
// Start event handling
const auto CallbackId = Domain->SubscribeSubscribes(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeSubscribes(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
subscribe
Subscribe to a Room
Subscribing to a room allows you to receive notifications of new messages posted for that room. You can choose to be notified only when a message has a specific category value, or only when a message has a specific category value. If you are offline when you receive a notification, you can set up a mobile push notification to be forwarded to you.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
roomName | string | ✓ | ~ 128 chars | Room name to subscribe to | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
notificationTypes | List<EzNotificationType> | [] | ~ 100 items | Category list to receive notifications of new messages |
Result
Type | Description | |
---|---|---|
item | EzSubscribe | Subscribed Subscriptions |
Implementation Example
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Subscribe(
roomName: "room-0001"
);
var result = await domain.SubscribeAsync(
notificationTypes: new List<Gs2.Unity.Gs2Chat.Model.EzNotificationType> {
new Gs2.Unity.Gs2Chat.Model.EzNotificationType {
},
}
);
var item = await result.ModelAsync();
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Subscribe(
roomName: "room-0001"
);
var future = domain.SubscribeFuture(
notificationTypes: new List<Gs2.Unity.Gs2Chat.Model.EzNotificationType> {
new Gs2.Unity.Gs2Chat.Model.EzNotificationType {
},
}
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Subscribe(
"room-0001" // roomName
);
const auto Future = Domain->Subscribe(
[]
{
auto v = MakeShared<TArray<TSharedPtr<Gs2::UE5::Chat::Model::FEzNotificationType>>>();
v->Add(
MakeShared<Gs2::UE5::Chat::Model::FEzNotificationType>());
return v;
}() // notificationTypes
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (Future2->GetTask().IsError())
{
return Future2->GetTask().Error();
}
const auto Result = Future2->GetTask().Result();
unsubscribe
Unsubscribe
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
roomName | string | ✓ | ~ 128 chars | Room name to subscribe to | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
item | EzSubscribe | Unsubscribed subscriptions |
Implementation Example
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Subscribe(
roomName: "room-0001"
);
var result = await domain.UnsubscribeAsync(
);
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Subscribe(
roomName: "room-0001"
);
var future = domain.UnsubscribeFuture(
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Subscribe(
"room-0001" // roomName
);
const auto Future = Domain->Unsubscribe(
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
const auto Result = Future->GetTask().Result();
updateSubscribeSetting
Updating Subscription Preferences
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
roomName | string | ✓ | ~ 128 chars | Room name to subscribe to | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
notificationTypes | List<EzNotificationType> | [] | ~ 100 items | Category list to receive notifications of new messages |
Result
Type | Description | |
---|---|---|
item | EzSubscribe | Renewed Subscriptions |
Implementation Example
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Subscribe(
roomName: "room-0001"
);
var result = await domain.UpdateSubscribeSettingAsync(
notificationTypes: new List<Gs2.Unity.Gs2Chat.Model.EzNotificationType> {
new Gs2.Unity.Gs2Chat.Model.EzNotificationType() {},
}
);
var item = await result.ModelAsync();
var domain = gs2.Chat.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Subscribe(
roomName: "room-0001"
);
var future = domain.UpdateSubscribeSettingFuture(
notificationTypes: new List<Gs2.Unity.Gs2Chat.Model.EzNotificationType> {
new Gs2.Unity.Gs2Chat.Model.EzNotificationType() {},
}
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Chat->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Subscribe(
"room-0001" // roomName
);
const auto Future = Domain->UpdateSubscribeSetting(
[]
{
auto v = MakeShared<TArray<TSharedPtr<Gs2::UE5::Chat::Model::FEzNotificationType>>>();
v->Add(
MakeShared<Gs2::UE5::Chat::Model::FEzNotificationType>() {});
return v;
}() // notificationTypes
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (Future2->GetTask().IsError())
{
return Future2->GetTask().Error();
}
const auto Result = Future2->GetTask().Result();
Event Handler
OnPostNotification
Notification used when a new post is made to a room to which you are subscribed
Name | Type | Description |
---|---|---|
namespaceName | string | Namespace name |
roomName | string | Room Name |
userId | string | User Id |
category | int | Type number when you want to classify message types. |
createdAt | long | Datetime of creation |
Implementation Example
gs2.Chat.OnPostNotification += notification =>
{
var namespaceName = notification.NamespaceName;
var roomName = notification.RoomName;
var userId = notification.UserId;
var category = notification.Category;
var createdAt = notification.CreatedAt;
};
gs2.Chat.OnPostNotification += notification =>
{
var namespaceName = notification.NamespaceName;
var roomName = notification.RoomName;
var userId = notification.UserId;
var category = notification.Category;
var createdAt = notification.CreatedAt;
};
Gs2->Chat->OnPostNotification().AddLambda([](const auto Notification)
{
const auto NamespaceName = Notification->NamespaceNameValue;
const auto RoomName = Notification->RoomNameValue;
const auto UserId = Notification->UserIdValue;
const auto Category = Notification->CategoryValue;
const auto CreatedAt = Notification->CreatedAtValue;
});