Stream Chat Unreal SDK
Loading...
Searching...
No Matches
UChatChannel Class Referencefinal

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 UChatChannelCreate (UObject *Outer, const TSharedRef< FChatApi >, const TSharedRef< IChatSocket >, const FChannelStateResponseFieldsDto &)
 Create a new channel object.
 
static UChatChannelCreate (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)
 

Detailed Description

The client-side representation of a Stream Chat channel.

Member Function Documentation

◆ AddMembers()

void UChatChannel::AddMembers ( const TArray< FString > &  MemberIds,
const TOptional< FMessage > &  Message = {},
TFunction< void()>  Callback = {} 
)

Add given users as members.

Parameters
MemberIdsIDs of users to add to the channel as members
MessageOptionally include a message object that will be used to populate a system message
CallbackCalled when response is received.

◆ BanMemberBP()

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.

Parameters
UserUser to ban
TimeoutTimeout of ban in minutes. User will be unbanned after this period of time (unlimited if zero)
ReasonBan reason (optional)
bIpBanWhether to perform IP ban or not

◆ Delete()

void UChatChannel::Delete ( TFunction< void()>  Callback = {}) const

Delete this channel from the server.

Parameters
CallbackCalled when response is received.

◆ DeleteMessage()

void UChatChannel::DeleteMessage ( const FMessage Message)

Soft delete a message in this channel.

Parameters
MessageMessage which already exists in this channel

◆ DeleteReaction()

void UChatChannel::DeleteReaction ( const FMessage Message,
const FReaction Reaction 
)

Remove a reaction from a given message.

Parameters
MessageThe message in this channel to react to
ReactionThe reaction to remove

◆ GetMessageBP()

void UChatChannel::GetMessageBP ( const FString &  MessageId,
const UObject *  WorldContextObject,
FLatentActionInfo  LatentInfo,
FMessage OutMessage 
)

Get a single message by its ID from the server.

◆ GetReactions()

void UChatChannel::GetReactions ( const FMessage Message,
const FPaginationOptions Pagination = {},
TFunction< void(const TArray< FReaction > &)>  Callback = {} 
)

Fetch or paginate more reactions for a given message.

Parameters
MessageThe message in this channel to fetch reactions for
PaginationLimit and offset for pagination of reactions
CallbackCalled when response is received

◆ Hide()

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.

Parameters
bClearHistoryClear the entire message history of that channel for the user
CallbackCalled when response is received.

◆ KeyStroke()

void UChatChannel::KeyStroke ( const FString &  ParentMessageId = TEXT(""))

Should be called on every keystroke. Sends typing.start and typing.stop events accordingly.

Parameters
ParentMessageIdIn the case of a thread, the ID of the parent message (optional)

◆ MarkRead() [1/2]

void UChatChannel::MarkRead ( const FMessage Message)

Manually mark all messages in this channel as read by the current user.

Parameters
MessageOptionally provide a Message that is considered last read

◆ MarkRead() [2/2]

void UChatChannel::MarkRead ( const TOptional< FMessage > &  Message = {})

Manually mark all messages in this channel as read by the current user.

Parameters
MessageOptionally provide a Message that is considered last read

◆ MuteBP()

void UChatChannel::MuteBP ( FTimespan  Timeout)

Mutes channel for current user.

Parameters
TimeoutDuration of mute (never unmuted if left zero)

◆ On() [1/3]

template<class TEvent , typename FunctorType , typename... VarTypes>
TEnableIf< TIsInvocable< FunctorType, constTEvent &, VarTypes... >::Value, FDelegateHandle >::Type UChatChannel::On ( FunctorType &&  Functor,
VarTypes...  Vars 
)

Subscribe to a channel event using a C++ lambda.

Template Parameters
TEventEvent type
Parameters
FunctorLambda to execute when event occurs. Should have signature similar to: [](const TEvent& Event){}
VarsAdditional variables to pass to the lambda
Returns
A handle which can be used to unsubscribe from the event

◆ On() [2/3]

template<class TEvent , class UserClass >
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.

Template Parameters
TEventEvent type
Parameters
ObjObject with given method
MethodMethod to call when event occurs. Should have signature: void OnMyEvent(const TEvent& Event)
Returns
A handle which can be used to unsubscribe from the event

◆ On() [3/3]

template<class TEvent , class UserClass >
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.

Template Parameters
TEventEvent type
Parameters
ObjUObject with given method
MethodMethod to call when event occurs. Should have signature: void OnMyEvent(const TEvent& Event)
Returns
A handle which can be used to unsubscribe from the event

◆ PartialUpdate()

void UChatChannel::PartialUpdate ( const TSharedRef< FJsonObject > &  Set = {},
const TArray< FString > &  Unset = {},
TFunction< void()>  Callback = {} 
)

Updates certain fields of the channel.

Parameters
SetSets new field values
UnsetArray of field names to unset
CallbackCalled when response is received.

◆ Query()

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.

Parameters
CallbackCalled when response is received.
FlagsAdditional actions to perform, like watch, or fetch presence.
See also
EChannelFlags
Parameters
MessagePaginationPagination details for returned messages.
See also
https://getstream.io/chat/docs/unreal/channel_pagination/
Parameters
MemberPaginationPagination details for returned members.
WatcherPaginationPagination details for returned watchers/

◆ QueryAdditionalMessages()

void UChatChannel::QueryAdditionalMessages ( EPaginationDirection  Direction = EPaginationDirection::Top,
int32  Limit = 20,
TFunction< void()>  Callback = {} 
)

Fetch more messages from the server.

Attention
Some messages must already have been fetched for this to do anything.
Parameters
DirectionTop if the user is scrolling up, Bottom if the user is scrolling down
LimitNumber of messages returned is limited by this value. Maximum 200.
CallbackCalled when a response is received from the backend

◆ QueryMembers()

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.

Parameters
FilterConditions to use to filter the members
SortThe sorting used for the members matching the filters. Sorting is based on field and direction, multiple sorting options can be provided.
PaginationLimit, offset, and member selection by user id GtId, GteId, LtId and LteId fields are for user IDs
CallbackCalled when response is received.

◆ RemoveMembers()

void UChatChannel::RemoveMembers ( const TArray< FString > &  MemberIds,
const TOptional< FMessage > &  Message = {},
TFunction< void()>  Callback = {} 
)

Remove given users as members.

Parameters
MemberIdsIDs of users to remove from the channel as members
MessageOptionally include a message object that will be used to populate a system message
CallbackCalled when response is received.

◆ SearchMessages() [1/2]

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

Parameters
QuerySearch phrase (Optional)
MessageFilterMessage filter conditions (Optional)
SortSort parameters (Optional)
MessageLimitNumber of messages to return (Optional)
OutMessagesThe result of the search

◆ SearchMessages() [2/2]

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

Parameters
QuerySearch phrase
MessageFilterMessage filter conditions
SortSort parameters. Cannot be used with non-zero offset.
MessageLimitNumber of messages to return
CallbackCalled when response is received

◆ SendMessageBP()

void UChatChannel::SendMessageBP ( const FMessage Message,
const UObject *  WorldContextObject,
FLatentActionInfo  LatentInfo,
bool &  bSuccess 
)

Send a message on this channel.

Parameters
MessageA message struct containing information of the message to be sent

◆ SendReaction()

FReaction UChatChannel::SendReaction ( const FMessage Message,
const FName &  ReactionType,
int32  Score = 1,
bool  bEnforceUnique = false 
)

Add a reaction to a given message.

Parameters
MessageThe message in this channel to react to
ReactionTypeThe type of reaction to send
bEnforceUniqueShould all other reactions from this user be removed
ScoreThe score of the reaction. Defaults to 1.

◆ ShadowBanMemberBP()

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.

Parameters
UserUser to shadow ban
TimeoutTimeout of ban in minutes. User will be unbanned after this period of time (never unbanned if zero)

◆ ShadowUnbanMember()

void UChatChannel::ShadowUnbanMember ( const FUserRef User) const

Remove previously applied shadow ban.

Parameters
UserUser to unban

◆ Show()

void UChatChannel::Show ( TFunction< void()>  Callback = {}) const

Un-hide this channel. It will again appear in query channel requests for the current user.

Parameters
CallbackCalled when response is received.

◆ StopTyping()

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()

Parameters
ParentMessageIdIn the case of a thread, the ID of the parent message (optional)

◆ StopWatching()

void UChatChannel::StopWatching ( TFunction< void()>  Callback = {}) const

Stop receiving channel events.

Parameters
CallbackCalled when response is received.

◆ Truncate()

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.

Parameters
bHardDeleteActually delete messages, instead of soft-deleting (hiding) them
TruncatedAtTruncate this channel only up to given time
MessageA system message to be added after truncation
bSkipPushIf a message is included, don't send the push notification
CallbackCalled when response is received

◆ UnbanMember()

void UChatChannel::UnbanMember ( const FUserRef User) const

Remove previously applied ban.

Parameters
UserUser to unban

◆ Unsubscribe()

template<class TEvent >
bool UChatChannel::Unsubscribe ( FDelegateHandle  Handle) const

Unsubscribe from a previously subscribed channel event.

Template Parameters
TEventEvent type
Returns
Whether anything was unsubscribed from

◆ Update()

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.

Parameters
DataProperties to set on the channel
MessageOptionally include a message object that will be used to populate a system message
CallbackCalled when response is received.

◆ UpdateMessage()

void UChatChannel::UpdateMessage ( const FMessage Message)

Update (user might see "Edit") a message which exists on this channel.

Parameters
MessageMessage which already exists in this channel

The documentation for this class was generated from the following files: