Stream Chat Unreal SDK
|
The client-side representation of a Stream Chat channel. More...
#include <ChatChannel.h>
Inherits UObject.
Public Member Functions | |
bool | IsValid () const |
Does this represent a non-null channel? | |
void | Delete (TFunction< void()> Callback={}) const |
Delete this channel from the server. More... | |
void | PartialUpdate (const TSharedRef< FJsonObject > &Set={}, const TArray< FString > &Unset={}, TFunction< void()> Callback={}) |
Updates certain fields of the channel. More... | |
void | Update (const FAdditionalFields &Data, const TOptional< FMessage > &Message={}, TFunction< void()> Callback={}) |
Change channel data. Any data that is present on the channel and not included in a full update will be deleted. More... | |
void | Truncate (bool bHardDelete=false, const TOptional< FDateTime > &TruncatedAt={}, const TOptional< FMessage > &Message={}, bool bSkipPush=false, TFunction< void()> Callback={}) |
Delete all messages in this channel. More... | |
void | QueryMembers (const FFilter &Filter={}, const TArray< FUserSortOption > &Sort={}, const FMessagePaginationOptions &Pagination={}, TFunction< void(const TArray< FMember > &)> Callback={}) |
List and paginate members for this channel. More... | |
void | AddMembers (const TArray< FString > &MemberIds, const TOptional< FMessage > &Message={}, TFunction< void()> Callback={}) |
Add given users as members. More... | |
void | RemoveMembers (const TArray< FString > &MemberIds, const TOptional< FMessage > &Message={}, TFunction< void()> Callback={}) |
Remove given users as members. More... | |
void | Hide (bool bClearHistory=false, TFunction< void()> Callback={}) const |
Remove this channel from query channel requests for the current user until a new message is added. Hiding a channel is only available to members of that channel. More... | |
void | Show (TFunction< void()> Callback={}) const |
Un-hide this channel. It will again appear in query channel requests for the current user. More... | |
void | StopWatching (TFunction< void()> Callback={}) const |
Stop receiving channel events. More... | |
Event | |
Send, subscribe and unsubscribe to events | |
template<class TEvent > | |
void | SendEvent (const TEvent &) |
Send a custom event on this channel. | |
template<class TEvent > | |
FDelegateHandle | On (TEventDelegate< TEvent > Callback) |
Subscribe to a channel event using your own delegate object. | |
template<class TEvent , class UserClass > | |
TEnableIf< TIsDerivedFrom< UserClass, UObject >::IsDerived, FDelegateHandle >::Type | On (UserClass *Obj, TEventDelegateUObjectMethodPtr< TEvent, UserClass > Method) |
Subscribe to a channel event using a UObject-based member function delegate. More... | |
template<class TEvent , class UserClass > | |
TEnableIf<!TIsDerivedFrom< UserClass, UObject >::IsDerived, FDelegateHandle >::Type | On (UserClass *Obj, TEventDelegateSpMethodPtr< TEvent, UserClass > Method) |
Subscribe to a channel event using a shared pointer-based (fast, not thread-safe) member function delegate. More... | |
template<class TEvent , typename FunctorType , typename... VarTypes> | |
TEnableIf< TIsInvocable< FunctorType, constTEvent &, VarTypes... >::Value, FDelegateHandle >::Type | On (FunctorType &&Functor, VarTypes... Vars) |
Subscribe to a channel event using a C++ lambda. More... | |
template<class TEvent > | |
bool | Unsubscribe (FDelegateHandle) const |
Unsubscribe from a previously subscribed channel event. More... | |
Static Public Member Functions | |
static UChatChannel * | Create (UObject *Outer, const TSharedRef< FChatApi >, const TSharedRef< IChatSocket >, const FChannelStateResponseFieldsDto &) |
Create a new channel object. | |
static UChatChannel * | Create (UObject *Outer, const TSharedRef< FChatApi >, const TSharedRef< IChatSocket >) |
Create a new null channel object. | |
Public Attributes | |
FChannelProperties | Properties |
The local static properties of the channel. | |
FChannelState | State |
The local state of the channel. | |
Message | |
Paginate, send, update and delete messages. | |
FMessagesUpdatedDelegate | MessagesUpdated |
Fired when any of the messages we have locally change. | |
FMessageDelegate | MessageSent |
Fired when a message is first sent client-side. | |
FMessageDelegate | MessageReceived |
Fired when a message is first received from the server (but not updated, deleted, etc) | |
FUnreadChangedDelegate | UnreadChanged |
Fired when the unread count changes for the current user. | |
void | SendMessageBP (const FMessage &Message, const UObject *WorldContextObject, FLatentActionInfo LatentInfo, bool &bSuccess) |
Send a message on this channel. More... | |
void | SendMessage (const FMessage &Message, const TFunction< void(const bool &bSuccess)>={}) |
void | GetMessageBP (const FString &MessageId, const UObject *WorldContextObject, FLatentActionInfo LatentInfo, FMessage &OutMessage) |
Get a single message by its ID from the server. More... | |
void | GetMessage (const FString &MessageId, const TFunction< void(const FMessage &)> Callback={}) |
void | UpdateMessage (const FMessage &Message) |
Update (user might see "Edit") a message which exists on this channel. More... | |
void | DeleteMessage (const FMessage &Message) |
Soft delete a message in this channel. More... | |
void | QueryAdditionalMessages (EPaginationDirection Direction=EPaginationDirection::Top, int32 Limit=20, TFunction< void()> Callback={}) |
Fetch more messages from the server. More... | |
void | MarkRead (const TOptional< FMessage > &Message={}) |
Manually mark all messages in this channel as read by the current user. More... | |
void | MarkRead (const FMessage &Message) |
Manually mark all messages in this channel as read by the current user. More... | |
void | MarkReadLocal () |
Clear unread count locally. | |
void | Query (EChannelFlags Flags=EChannelFlags::State, const TOptional< FMessagePaginationOptions > MessagePagination={}, const TOptional< FUserPaginationOptions > MemberPagination={}, const TOptional< FUserPaginationOptions > WatcherPagination={}, TFunction< void()> Callback={}) |
Get messages, members or other channel fields. More... | |
void | SearchMessages (const TOptional< FString > &Query={}, const TOptional< FFilter > &MessageFilter={}, const TArray< FMessageSortOption > &Sort={}, TOptional< uint32 > MessageLimit={}, TFunction< void(const TArray< FMessage > &)> Callback={}) const |
Search the messages in this channel. More... | |
void | SearchMessages (const FString &Query, const FFilter &MessageFilter, const TArray< FMessageSortOption > &Sort, int32 MessageLimit, const UObject *WorldContextObject, FLatentActionInfo LatentInfo, TArray< FMessage > &OutMessages) |
Search the messages in this channel. More... | |
Typing | |
FTypingIndicatorDelegate | OnTypingIndicator |
Fired whenever any user starts or stops typing. | |
void | KeyStroke (const FString &ParentMessageId=TEXT("")) |
Should be called on every keystroke. Sends typing.start and typing.stop events accordingly. More... | |
void | StopTyping (const FString &ParentMessageId=TEXT("")) |
Should be called when the user sends the message (or aborts). Manually sends the typing.stop event, and cancels any pending typing.stop event queued by Keystroke() More... | |
Reaction | |
Send and delete reactions. | |
FReaction | SendReaction (const FMessage &Message, const FName &ReactionType, int32 Score=1, bool bEnforceUnique=false) |
Add a reaction to a given message. More... | |
void | GetReactions (const FMessage &Message, const FPaginationOptions &Pagination={}, TFunction< void(const TArray< FReaction > &)> Callback={}) |
Fetch or paginate more reactions for a given message. More... | |
void | DeleteReaction (const FMessage &Message, const FReaction &Reaction) |
Remove a reaction from a given message. More... | |
Moderation | |
void | BanMemberBP (const FUserRef &User, FTimespan Timeout, FString Reason, bool bIpBan) const |
Ban a member from this channel. When a user is banned, they will not be allowed to post messages until the ban is removed or expired but will be able to connect to Chat and to channels as before. More... | |
void | BanMember (const FUserRef &User, const TOptional< FTimespan > &Timeout={}, const TOptional< FString > &Reason={}, bool bIpBan=false) const |
void | UnbanMember (const FUserRef &User) const |
Remove previously applied ban. More... | |
void | ShadowBanMemberBP (const FUserRef &User, FTimespan Timeout) const |
Shadow ban a member from this channel. When a user is shadow banned, they will still be allowed to post messages, but any message sent during the will only be visible to the messages author and invisible to other users of the App. More... | |
void | ShadowBanMember (const FUserRef &User, const TOptional< FTimespan > &Timeout={}) const |
void | ShadowUnbanMember (const FUserRef &User) const |
Remove previously applied shadow ban. More... | |
void | MuteBP (FTimespan Timeout) |
Mutes channel for current user. More... | |
void | Mute (const TOptional< FTimespan > &Timeout={}) |
void | Unmute () const |
Unmutes channel for current user. | |
bool | IsMuted () const |
Is this channel muted for the current user. | |
void | EnableSlowMode (FTimespan Cooldown) |
Enable slow mode with the given cooldown. | |
void | DisableSlowMode () |
Disable slow mode (no more cooldown between consecutive messages) | |
The client-side representation of a Stream Chat channel.
void UChatChannel::AddMembers | ( | const TArray< FString > & | MemberIds, |
const TOptional< FMessage > & | Message = {} , |
||
TFunction< void()> | Callback = {} |
||
) |
Add given users as members.
MemberIds | IDs of users to add to the channel as members |
Message | Optionally include a message object that will be used to populate a system message |
Callback | Called when response is received. |
void UChatChannel::BanMemberBP | ( | const FUserRef & | User, |
FTimespan | Timeout, | ||
FString | Reason, | ||
bool | bIpBan | ||
) | const |
Ban a member from this channel. When a user is banned, they will not be allowed to post messages until the ban is removed or expired but will be able to connect to Chat and to channels as before.
User | User to ban |
Timeout | Timeout of ban in minutes. User will be unbanned after this period of time (unlimited if zero) |
Reason | Ban reason (optional) |
bIpBan | Whether to perform IP ban or not |
void UChatChannel::Delete | ( | TFunction< void()> | Callback = {} | ) | const |
Delete this channel from the server.
Callback | Called when response is received. |
void UChatChannel::DeleteMessage | ( | const FMessage & | Message | ) |
Soft delete a message in this channel.
Message | Message which already exists in this channel |
Remove a reaction from a given message.
Message | The message in this channel to react to |
Reaction | The reaction to remove |
void UChatChannel::GetMessageBP | ( | const FString & | MessageId, |
const UObject * | WorldContextObject, | ||
FLatentActionInfo | LatentInfo, | ||
FMessage & | OutMessage | ||
) |
Get a single message by its ID from the server.
void UChatChannel::GetReactions | ( | const FMessage & | Message, |
const FPaginationOptions & | Pagination = {} , |
||
TFunction< void(const TArray< FReaction > &)> | Callback = {} |
||
) |
Fetch or paginate more reactions for a given message.
Message | The message in this channel to fetch reactions for |
Pagination | Limit and offset for pagination of reactions |
Callback | Called when response is received |
void UChatChannel::Hide | ( | bool | bClearHistory = false , |
TFunction< void()> | Callback = {} |
||
) | const |
Remove this channel from query channel requests for the current user until a new message is added. Hiding a channel is only available to members of that channel.
bClearHistory | Clear the entire message history of that channel for the user |
Callback | Called when response is received. |
void UChatChannel::KeyStroke | ( | const FString & | ParentMessageId = TEXT("") | ) |
Should be called on every keystroke. Sends typing.start
and typing.stop
events accordingly.
ParentMessageId | In the case of a thread, the ID of the parent message (optional) |
void UChatChannel::MarkRead | ( | const FMessage & | Message | ) |
Manually mark all messages in this channel as read by the current user.
Message | Optionally provide a Message that is considered last read |
void UChatChannel::MarkRead | ( | const TOptional< FMessage > & | Message = {} | ) |
Manually mark all messages in this channel as read by the current user.
Message | Optionally provide a Message that is considered last read |
void UChatChannel::MuteBP | ( | FTimespan | Timeout | ) |
Mutes channel for current user.
Timeout | Duration of mute (never unmuted if left zero) |
TEnableIf< TIsInvocable< FunctorType, constTEvent &, VarTypes... >::Value, FDelegateHandle >::Type UChatChannel::On | ( | FunctorType && | Functor, |
VarTypes... | Vars | ||
) |
Subscribe to a channel event using a C++ lambda.
TEvent | Event type |
Functor | Lambda to execute when event occurs. Should have signature similar to: [](const TEvent& Event){} |
Vars | Additional variables to pass to the lambda |
TEnableIf<!TIsDerivedFrom< UserClass, UObject >::IsDerived, FDelegateHandle >::Type UChatChannel::On | ( | UserClass * | Obj, |
TEventDelegateSpMethodPtr< TEvent, UserClass > | Method | ||
) |
Subscribe to a channel event using a shared pointer-based (fast, not thread-safe) member function delegate.
TEvent | Event type |
Obj | Object with given method |
Method | Method to call when event occurs. Should have signature: void OnMyEvent(const TEvent& Event) |
TEnableIf<!TIsDerivedFrom< UserClass, UObject >::IsDerived, FDelegateHandle >::Type UChatChannel::On | ( | UserClass * | Obj, |
TEventDelegateUObjectMethodPtr< TEvent, UserClass > | Method | ||
) |
Subscribe to a channel event using a UObject-based member function delegate.
TEvent | Event type |
Obj | UObject with given method |
Method | Method to call when event occurs. Should have signature: void OnMyEvent(const TEvent& Event) |
void UChatChannel::PartialUpdate | ( | const TSharedRef< FJsonObject > & | Set = {} , |
const TArray< FString > & | Unset = {} , |
||
TFunction< void()> | Callback = {} |
||
) |
Updates certain fields of the channel.
Set | Sets new field values |
Unset | Array of field names to unset |
Callback | Called when response is received. |
void UChatChannel::Query | ( | EChannelFlags | Flags = EChannelFlags::State , |
const TOptional< FMessagePaginationOptions > | MessagePagination = {} , |
||
const TOptional< FUserPaginationOptions > | MemberPagination = {} , |
||
const TOptional< FUserPaginationOptions > | WatcherPagination = {} , |
||
TFunction< void()> | Callback = {} |
||
) |
Get messages, members or other channel fields.
Callback | Called when response is received. |
Flags | Additional actions to perform, like watch, or fetch presence. |
MessagePagination | Pagination details for returned messages. |
MemberPagination | Pagination details for returned members. |
WatcherPagination | Pagination details for returned watchers/ |
void UChatChannel::QueryAdditionalMessages | ( | EPaginationDirection | Direction = EPaginationDirection::Top , |
int32 | Limit = 20 , |
||
TFunction< void()> | Callback = {} |
||
) |
Fetch more messages from the server.
Direction | Top if the user is scrolling up, Bottom if the user is scrolling down |
Limit | Number of messages returned is limited by this value. Maximum 200. |
Callback | Called when a response is received from the backend |
void UChatChannel::QueryMembers | ( | const FFilter & | Filter = {} , |
const TArray< FUserSortOption > & | Sort = {} , |
||
const FMessagePaginationOptions & | Pagination = {} , |
||
TFunction< void(const TArray< FMember > &)> | Callback = {} |
||
) |
List and paginate members for this channel.
Filter | Conditions to use to filter the members |
Sort | The sorting used for the members matching the filters. Sorting is based on field and direction, multiple sorting options can be provided. |
Pagination | Limit, offset, and member selection by user id GtId, GteId, LtId and LteId fields are for user IDs |
Callback | Called when response is received. |
void UChatChannel::RemoveMembers | ( | const TArray< FString > & | MemberIds, |
const TOptional< FMessage > & | Message = {} , |
||
TFunction< void()> | Callback = {} |
||
) |
Remove given users as members.
MemberIds | IDs of users to remove from the channel as members |
Message | Optionally include a message object that will be used to populate a system message |
Callback | Called when response is received. |
void UChatChannel::SearchMessages | ( | const FString & | Query, |
const FFilter & | MessageFilter, | ||
const TArray< FMessageSortOption > & | Sort, | ||
int32 | MessageLimit, | ||
const UObject * | WorldContextObject, | ||
FLatentActionInfo | LatentInfo, | ||
TArray< FMessage > & | OutMessages | ||
) |
Search the messages in this channel.
All parameters are optional, but a minimum of either a query or message filter is required
Query | Search phrase (Optional) |
MessageFilter | Message filter conditions (Optional) |
Sort | Sort parameters (Optional) |
MessageLimit | Number of messages to return (Optional) |
OutMessages | The result of the search |
void UChatChannel::SearchMessages | ( | const TOptional< FString > & | Query = {} , |
const TOptional< FFilter > & | MessageFilter = {} , |
||
const TArray< FMessageSortOption > & | Sort = {} , |
||
TOptional< uint32 > | MessageLimit = {} , |
||
TFunction< void(const TArray< FMessage > &)> | Callback = {} |
||
) | const |
Search the messages in this channel.
All parameters are optional, but a minimum of either a query or message filter is required
Query | Search phrase |
MessageFilter | Message filter conditions |
Sort | Sort parameters. Cannot be used with non-zero offset. |
MessageLimit | Number of messages to return |
Callback | Called when response is received |
void UChatChannel::SendMessageBP | ( | const FMessage & | Message, |
const UObject * | WorldContextObject, | ||
FLatentActionInfo | LatentInfo, | ||
bool & | bSuccess | ||
) |
Send a message on this channel.
Message | A message struct containing information of the message to be sent |
FReaction UChatChannel::SendReaction | ( | const FMessage & | Message, |
const FName & | ReactionType, | ||
int32 | Score = 1 , |
||
bool | bEnforceUnique = false |
||
) |
Add a reaction to a given message.
Message | The message in this channel to react to |
ReactionType | The type of reaction to send |
bEnforceUnique | Should all other reactions from this user be removed |
Score | The score of the reaction. Defaults to 1. |
void UChatChannel::ShadowBanMemberBP | ( | const FUserRef & | User, |
FTimespan | Timeout | ||
) | const |
Shadow ban a member from this channel. When a user is shadow banned, they will still be allowed to post messages, but any message sent during the will only be visible to the messages author and invisible to other users of the App.
User | User to shadow ban |
Timeout | Timeout of ban in minutes. User will be unbanned after this period of time (never unbanned if zero) |
void UChatChannel::ShadowUnbanMember | ( | const FUserRef & | User | ) | const |
Remove previously applied shadow ban.
User | User to unban |
void UChatChannel::Show | ( | TFunction< void()> | Callback = {} | ) | const |
Un-hide this channel. It will again appear in query channel requests for the current user.
Callback | Called when response is received. |
void UChatChannel::StopTyping | ( | const FString & | ParentMessageId = TEXT("") | ) |
Should be called when the user sends the message (or aborts). Manually sends the typing.stop event, and cancels any pending typing.stop event queued by Keystroke()
ParentMessageId | In the case of a thread, the ID of the parent message (optional) |
void UChatChannel::StopWatching | ( | TFunction< void()> | Callback = {} | ) | const |
Stop receiving channel events.
Callback | Called when response is received. |
void UChatChannel::Truncate | ( | bool | bHardDelete = false , |
const TOptional< FDateTime > & | TruncatedAt = {} , |
||
const TOptional< FMessage > & | Message = {} , |
||
bool | bSkipPush = false , |
||
TFunction< void()> | Callback = {} |
||
) |
Delete all messages in this channel.
bHardDelete | Actually delete messages, instead of soft-deleting (hiding) them |
TruncatedAt | Truncate this channel only up to given time |
Message | A system message to be added after truncation |
bSkipPush | If a message is included, don't send the push notification |
Callback | Called when response is received |
void UChatChannel::UnbanMember | ( | const FUserRef & | User | ) | const |
Remove previously applied ban.
User | User to unban |
bool UChatChannel::Unsubscribe | ( | FDelegateHandle | Handle | ) | const |
Unsubscribe from a previously subscribed channel event.
TEvent | Event type |
void UChatChannel::Update | ( | const FAdditionalFields & | Data, |
const TOptional< FMessage > & | Message = {} , |
||
TFunction< void()> | Callback = {} |
||
) |
Change channel data. Any data that is present on the channel and not included in a full update will be deleted.
Data | Properties to set on the channel |
Message | Optionally include a message object that will be used to populate a system message |
Callback | Called when response is received. |
void UChatChannel::UpdateMessage | ( | const FMessage & | Message | ) |
Update (user might see "Edit") a message which exists on this channel.
Message | Message which already exists in this channel |