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

A component which allows for connecting to the Stream Chat API. Should be added to a client-side actor, e.g. HUD. More...

#include <StreamChatClientComponent.h>

Inherits UActorComponent.

Public Member Functions

 UStreamChatClientComponent ()
 Initialize the component. Shouldn't be called directly.
 
void ConnectUser (const FUser &User, TUniquePtr< ITokenProvider > TokenProvider, TFunction< void(const FOwnUser &)> Callback={})
 Create a connection to the API for the given user and using a custom token provider. More...
 
void ConnectUser (const FUser &User, const FString &Token, TFunction< void(const FOwnUser &)> Callback={})
 Create a connection to the API for the given user and credentials. More...
 
void ConnectAnonymousUser (TFunction< void(const FOwnUser &)> Callback={})
 Create a connection to the API anonymously. More...
 
void ConnectGuestUser (const FUser &User, TFunction< void(const FOwnUser &)> Callback={})
 Create a connection to the API by creating a guest account. More...
 
void DisconnectUser ()
 Close the connection to the API and resets any state.
 
void UpsertUsers (const TArray< FUser > &Users)
 Create or update one or more users.
 
UChatChannelNewChat ()
 Create a null chat channel for starting a new chat/group.
 
void CancelNewChat ()
 Remove any null chat channels used for starting a new chat/group.
 
void QueryChannels (TOptional< FFilter > Filter={}, const TArray< FChannelSortOption > &SortOptions={}, const EChannelFlags Flags=EChannelFlags::State|EChannelFlags::Watch, const FPaginationOptions &PaginationOptions={}, TFunction< void(const TArray< UChatChannel * > &)> Callback={})
 Query the API for all channels which match the given filter. Will also automatically watch all channels. More...
 
void CreateChannel (const FChannelProperties &ChannelProperties, TFunction< void(UChatChannel *)> Callback)
 Create a channel if it does not exist yet (if this user has the right permissions). More...
 
void WatchChannel (const FChannelProperties &ChannelProperties, TFunction< void(UChatChannel *)> Callback)
 Create a channel if it does not exist yet (if this user has the right permissions), get data about the channel (including members, watchers and messages) and subscribe to future updates. More...
 
void QueryChannel (const FChannelProperties &ChannelProperties, const EChannelFlags Flags, TFunction< void(UChatChannel *)> Callback={})
 Create a channel if it does not exist yet (if this user has the right permissions). Includes options to get data about the channel (including members, watchers and messages), subscribe to future updates. More...
 
void QueryAdditionalChannels (int32 Limit=10, TFunction< void()> Callback={})
 Fetch more channels from the server. More...
 
void QueryUsers (const FFilter &Filter={}, const TArray< FUserSortOption > &Sort={}, bool bPresence=true, const TOptional< FPaginationOptions > PaginationOptions={}, TFunction< void(const TArray< FUserRef > &)> Callback={}) const
 Search for users and see if they are online/offline. More...
 
void SearchMessages (const FFilter &ChannelFilter={}, const TOptional< FString > &Query={}, const TOptional< FFilter > &MessageFilter={}, const TArray< FMessageSortOption > &Sort={}, TOptional< uint32 > MessageLimit={}, TFunction< void(const TArray< FMessage > &)> Callback={}) const
 Search all messages A channel filter is required. All other parameters are optional, but a minimum of either a query or message filter is additionally required. More...
 
void MarkAllRead () const
 Mark all channels as read for the current user.
 
const TArray< UChatChannel * > & GetChannels () const
 
void AddDevice (const FString &DeviceId, EPushProvider PushProvider) const
 Registering a device associates it with a user and tells the push provider to send new message notifications to the device. More...
 
void RemoveDevice (const FString &DeviceId) const
 Unregistering a device removes the device from the user and stops further new message notifications. More...
 
void ListDevices (TFunction< void(TArray< FDevice >)> Callback) const
 Returns a list of all available devices. More...
 
Blueprint
void ConnectUser (const FUser &User, const FString &Token, const UObject *WorldContextObject, FLatentActionInfo LatentInfo, FOwnUser &OutUser)
 
void ConnectAnonymousUser (const UObject *WorldContextObject, FLatentActionInfo LatentInfo, FOwnUser &OutUser)
 
void ConnectGuestUser (const FUser &User, const UObject *WorldContextObject, FLatentActionInfo LatentInfo, FOwnUser &OutUser)
 
void QueryChannels (FFilter Filter, const TArray< FChannelSortOption > &SortOptions, const UObject *WorldContextObject, FLatentActionInfo LatentInfo, TArray< UChatChannel * > &OutChannels, UPARAM(meta=(Bitmask, BitmaskEnum=EChannelFlags)) const int32 Flags=3)
 
void WatchChannel (const FChannelProperties &ChannelProperties, const UObject *WorldContextObject, FLatentActionInfo LatentInfo, UChatChannel *&OutChannel)
 
Moderation
void BanUserBP (const FUserRef &User, FTimespan Timeout, const FString &Reason, bool bIpBan) const
 Ban a user from app entirely 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 BanUser (const FUserRef &User, const TOptional< FTimespan > &Timeout={}, const TOptional< FString > &Reason={}, bool bIpBan=false) const
 
void UnbanUser (const FUserRef &User) const
 Remove previously applied app-wide ban. More...
 
void ShadowBanUserBP (const FUserRef &User, FTimespan Timeout) const
 Shadow ban a user from app entirely 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 ShadowBanUser (const FUserRef &User, const TOptional< FTimespan > &Timeout={}) const
 
void ShadowUnbanUser (const FUserRef &User) const
 Remove previously applied app-wide shadow ban. More...
 
void QueryBannedUsers (const FFilter &Filter, const TArray< FBanSortOption > &SortOptions={}, const TOptional< FBanPaginationOptions > PaginationOptions={}, const TFunction< void(const TArray< FBan > &)> Callback={})
 Find and filter channel-scoped or global user bans. More...
 
void FlagMessage (const FMessage &Message) const
 Flag message for moderation. More...
 
void FlagUser (const FUserRef &User) const
 Flag user for moderation. More...
 
void MuteUserBP (const FUserRef &User, FTimespan Timeout) const
 Mute the given user. More...
 
void MuteUser (const FUserRef &User, const TOptional< FTimespan > &Timeout={}) const
 
void UnmuteUser (const FUserRef &User) const
 Unmute a previously muted user. More...
 

Static Public Member Functions

static FString DevToken (const FString &UserId)
 

Public Attributes

FString ApiKey
 
FChannelsUpdatedDelegate ChannelsUpdated
 Fired when any of the channels we have locally change.
 

Events

template<class TEvent >
using TEventMulticastDelegate = TMulticastDelegate< void(const TEvent &Event)>
 
template<class TEvent >
using TEventDelegate = typename TEventMulticastDelegate< TEvent >::FDelegate
 
template<class TEvent , class UserClass >
using TEventDelegateUObjectMethodPtr = typename TEventDelegate< TEvent >::template TMethodPtr< UserClass >
 
template<class TEvent , class UserClass >
using TEventDelegateSpMethodPtr = typename TEventDelegate< TEvent >::template TMethodPtr< UserClass >
 
template<class TEvent >
FDelegateHandle On (TEventDelegate< TEvent > Callback)
 Subscribe to a client 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)
 
template<class TEvent , class UserClass >
TEnableIf<!TIsDerivedFrom< UserClass, UObject >::IsDerived, FDelegateHandle >::Type On (UserClass *Obj, TEventDelegateSpMethodPtr< TEvent, UserClass > Method)
 
template<class TEvent , typename FunctorType , typename... VarTypes>
TEnableIf< TIsInvocable< FunctorType, constTEvent &, VarTypes... >::Value, FDelegateHandle >::Type On (FunctorType &&Functor, VarTypes... Vars)
 
template<class TEvent >
bool Unsubscribe (FDelegateHandle) const
 

Detailed Description

A component which allows for connecting to the Stream Chat API. Should be added to a client-side actor, e.g. HUD.

Member Function Documentation

◆ AddDevice()

void UStreamChatClientComponent::AddDevice ( const FString &  DeviceId,
EPushProvider  PushProvider 
) const

Registering a device associates it with a user and tells the push provider to send new message notifications to the device.

Parameters
DeviceIdDevice-specific identifier
PushProviderWhich provider to use for push notifications

◆ BanUserBP()

void UStreamChatClientComponent::BanUserBP ( const FUserRef User,
FTimespan  Timeout,
const FString &  Reason,
bool  bIpBan 
) const

Ban a user from app entirely 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. User will be unbanned after this period of time (unlimited if zero)
ReasonBan reason (optional)
bIpBanWhether to perform IP ban or not

◆ ConnectAnonymousUser() [1/2]

void UStreamChatClientComponent::ConnectAnonymousUser ( const UObject *  WorldContextObject,
FLatentActionInfo  LatentInfo,
FOwnUser OutUser 
)

Create a connection to the API anonymously

Parameters
OutUserAnonymous user info

◆ ConnectAnonymousUser() [2/2]

void UStreamChatClientComponent::ConnectAnonymousUser ( TFunction< void(const FOwnUser &)>  Callback = {})

Create a connection to the API anonymously.

Parameters
CallbackCalled when a response is received from the API
Returns
Anonymous user info

◆ ConnectGuestUser() [1/2]

void UStreamChatClientComponent::ConnectGuestUser ( const FUser User,
const UObject *  WorldContextObject,
FLatentActionInfo  LatentInfo,
FOwnUser OutUser 
)

Create a connection to the API by creating a guest account

Parameters
UserGenerally only the user id is required
OutUserGuest user info

◆ ConnectGuestUser() [2/2]

void UStreamChatClientComponent::ConnectGuestUser ( const FUser User,
TFunction< void(const FOwnUser &)>  Callback = {} 
)

Create a connection to the API by creating a guest account.

Parameters
UserGenerally only the user id is required
CallbackCalled when a response is received from the API
Returns
Anonymous user info

◆ ConnectUser() [1/3]

void UStreamChatClientComponent::ConnectUser ( const FUser User,
const FString &  Token,
const UObject *  WorldContextObject,
FLatentActionInfo  LatentInfo,
FOwnUser OutUser 
)

Create a connection to the API for the given user and credentials.

Parameters
UserGenerally only the user id is required
TokenA JWT token for the given user
OutUserLatest info of the logged in user

◆ ConnectUser() [2/3]

void UStreamChatClientComponent::ConnectUser ( const FUser User,
const FString &  Token,
TFunction< void(const FOwnUser &)>  Callback = {} 
)

Create a connection to the API for the given user and credentials.

Parameters
UserGenerally only the user id is required
TokenA JWT token for the given user
CallbackCalled when a response is received from the API
Returns
Latest info if the logged in user

◆ ConnectUser() [3/3]

void UStreamChatClientComponent::ConnectUser ( const FUser User,
TUniquePtr< ITokenProvider >  TokenProvider,
TFunction< void(const FOwnUser &)>  Callback = {} 
)

Create a connection to the API for the given user and using a custom token provider.

Parameters
UserGenerally only the user id is required
TokenProviderCan be used to asynchronously generate tokens from your own backend
CallbackCalled when a response is received from the API
Returns
Latest info if the logged in user

◆ CreateChannel()

void UStreamChatClientComponent::CreateChannel ( const FChannelProperties ChannelProperties,
TFunction< void(UChatChannel *)>  Callback 
)

Create a channel if it does not exist yet (if this user has the right permissions).

Parameters
ChannelPropertiesProperties of the channel to create
CallbackCalled when a response is received from the API
Returns
A channel object which can be used to interact with the channel

◆ FlagMessage()

void UStreamChatClientComponent::FlagMessage ( const FMessage Message) const

Flag message for moderation.

Parameters
MessageA reference to an existing message

◆ FlagUser()

void UStreamChatClientComponent::FlagUser ( const FUserRef User) const

Flag user for moderation.

Parameters
UserA reference to a user

◆ ListDevices()

void UStreamChatClientComponent::ListDevices ( TFunction< void(TArray< FDevice >)>  Callback) const

Returns a list of all available devices.

Parameters
CallbackCalled when response is received

◆ MuteUserBP()

void UStreamChatClientComponent::MuteUserBP ( const FUserRef User,
FTimespan  Timeout 
) const

Mute the given user.

Parameters
TimeoutTimeout of ban. User will be unbanned after this period of time (unlimited if zero)
UserA reference to a user

◆ On() [1/3]

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

Subscribe to a client 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 UStreamChatClientComponent::On ( UserClass *  Obj,
TEventDelegateSpMethodPtr< TEvent, UserClass >  Method 
)

Subscribe to a client 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 UStreamChatClientComponent::On ( UserClass *  Obj,
TEventDelegateUObjectMethodPtr< TEvent, UserClass >  Method 
)

Subscribe to a client 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

◆ QueryAdditionalChannels()

void UStreamChatClientComponent::QueryAdditionalChannels ( int32  Limit = 10,
TFunction< void()>  Callback = {} 
)

Fetch more channels from the server.

Attention
Some messages must already have been fetched for this to do anything.
Parameters
LimitNumber of channels returned is limited by this value. Maximum 30.
CallbackCalled when a response is received from the backend

◆ QueryBannedUsers()

void UStreamChatClientComponent::QueryBannedUsers ( const FFilter Filter,
const TArray< FBanSortOption > &  SortOptions = {},
const TOptional< FBanPaginationOptions PaginationOptions = {},
const TFunction< void(const TArray< FBan > &)>  Callback = {} 
)

Find and filter channel-scoped or global user bans.

See also
https://getstream.io/chat/docs/unreal/moderation/#query-bans-endpoint
Parameters
FilterConditions to use to filter the banned users
SortOptionsThe sorting used for the banned users matching the filters. Sorting is based on field and direction, multiple sorting options can be provided.
PaginationOptionsPagination for bans can be done in two ways: using offset/limit or using the "created_at" field.
CallbackCalled when response is received.

◆ QueryChannel()

void UStreamChatClientComponent::QueryChannel ( const FChannelProperties ChannelProperties,
const EChannelFlags  Flags,
TFunction< void(UChatChannel *)>  Callback = {} 
)

Create a channel if it does not exist yet (if this user has the right permissions). Includes options to get data about the channel (including members, watchers and messages), subscribe to future updates.

Parameters
FlagsGet state, get presence and/or watch
ChannelPropertiesProperties of the channel to query
CallbackCalled when a response is received from the API
Returns
A channel object which can be used to interact with the channel

◆ QueryChannels() [1/2]

void UStreamChatClientComponent::QueryChannels ( FFilter  Filter,
const TArray< FChannelSortOption > &  SortOptions,
const UObject *  WorldContextObject,
FLatentActionInfo  LatentInfo,
TArray< UChatChannel * > &  OutChannels,
UPARAM(meta=(Bitmask, BitmaskEnum=EChannelFlags)) const int32  Flags = 3 
)

Query the API for all channels which match the given filter. Will also automatically watch all channels.

Parameters
FilterThe query filters to use. You can query on any of the custom fields you've defined on the Channel. As a minimum, the filter should be something like: { members: { $in: [userID] } }
SortOptionsThe sorting used for the channels matching the filters. Sorting is based on field and direction, and multiple sorting options can be provided.
FlagsGet state, get presence and/or watch
OutChannelsAn array of channel objects which can be used to interact with the channels

◆ QueryChannels() [2/2]

void UStreamChatClientComponent::QueryChannels ( TOptional< FFilter Filter = {},
const TArray< FChannelSortOption > &  SortOptions = {},
const EChannelFlags  Flags = EChannelFlags::State | EChannelFlags::Watch,
const FPaginationOptions PaginationOptions = {},
TFunction< void(const TArray< UChatChannel * > &)>  Callback = {} 
)

Query the API for all channels which match the given filter. Will also automatically watch all channels.

Parameters
CallbackCalled when a response is received from the API
FilterThe query filters to use. You can query on any of the custom fields you've defined on the Channel. As a minimum, the filter should be something like: { members: { $in: [userID] } }
SortOptionsThe sorting used for the channels matching the filters. Sorting is based on field and direction, and multiple sorting options can be provided.
FlagsGet state, get presence and/or watch
PaginationOptionsPagination offset and limit
Returns
An array of channel objects which can be used to interact with the channels

◆ QueryUsers()

void UStreamChatClientComponent::QueryUsers ( const FFilter Filter = {},
const TArray< FUserSortOption > &  Sort = {},
bool  bPresence = true,
const TOptional< FPaginationOptions PaginationOptions = {},
TFunction< void(const TArray< FUserRef > &)>  Callback = {} 
) const

Search for users and see if they are online/offline.

Parameters
bPresenceGet updates when the user goes offline/online
FilterConditions to use to filter the users,
See also
https://getstream.io/chat/docs/unreal/query_users
Parameters
SortThe sorting used for the users matching the filters. Sorting is based on field and direction, multiple sorting options can be provided.
PaginationOptionsThe number of users to return and pagination offset
CallbackCalled when response is received

◆ RemoveDevice()

void UStreamChatClientComponent::RemoveDevice ( const FString &  DeviceId) const

Unregistering a device removes the device from the user and stops further new message notifications.

Parameters
DeviceIdDevice-specific identifier

◆ SearchMessages()

void UStreamChatClientComponent::SearchMessages ( const FFilter ChannelFilter = {},
const TOptional< FString > &  Query = {},
const TOptional< FFilter > &  MessageFilter = {},
const TArray< FMessageSortOption > &  Sort = {},
TOptional< uint32 >  MessageLimit = {},
TFunction< void(const TArray< FMessage > &)>  Callback = {} 
) const

Search all messages A channel filter is required. All other parameters are optional, but a minimum of either a query or message filter is additionally required.

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

◆ ShadowBanUserBP()

void UStreamChatClientComponent::ShadowBanUserBP ( const FUserRef User,
FTimespan  Timeout 
) const

Shadow ban a user from app entirely 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. User will be unbanned after this period of time (unlimited if zero)

◆ ShadowUnbanUser()

void UStreamChatClientComponent::ShadowUnbanUser ( const FUserRef User) const

Remove previously applied app-wide shadow ban.

Parameters
UserUser to unban

◆ UnbanUser()

void UStreamChatClientComponent::UnbanUser ( const FUserRef User) const

Remove previously applied app-wide ban.

Parameters
UserUser to unban

◆ UnmuteUser()

void UStreamChatClientComponent::UnmuteUser ( const FUserRef User) const

Unmute a previously muted user.

Parameters
UserA reference to a user

◆ WatchChannel() [1/2]

void UStreamChatClientComponent::WatchChannel ( const FChannelProperties ChannelProperties,
const UObject *  WorldContextObject,
FLatentActionInfo  LatentInfo,
UChatChannel *&  OutChannel 
)

Create a channel if it does not exist yet (if this user has the right permissions), get data about the channel (including members, watchers and messages) and subscribe to future updates

Parameters
ChannelPropertiesProperties of the channel to watch
OutChannelObject which can be used to interact with the channel

◆ WatchChannel() [2/2]

void UStreamChatClientComponent::WatchChannel ( const FChannelProperties ChannelProperties,
TFunction< void(UChatChannel *)>  Callback 
)

Create a channel if it does not exist yet (if this user has the right permissions), get data about the channel (including members, watchers and messages) and subscribe to future updates.

Parameters
ChannelPropertiesProperties of the channel to watch
CallbackCalled when a response is received from the API
Returns
A channel object which can be used to interact with the channel

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