Stream Chat Unreal SDK
|
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. | |
UChatChannel * | NewChat () |
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 |
A component which allows for connecting to the Stream Chat API. Should be added to a client-side actor, e.g. HUD.
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.
DeviceId | Device-specific identifier |
PushProvider | Which provider to use for push notifications |
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.
User | User to ban |
Timeout | Timeout of ban. 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 UStreamChatClientComponent::ConnectAnonymousUser | ( | const UObject * | WorldContextObject, |
FLatentActionInfo | LatentInfo, | ||
FOwnUser & | OutUser | ||
) |
Create a connection to the API anonymously
OutUser | Anonymous user info |
void UStreamChatClientComponent::ConnectAnonymousUser | ( | TFunction< void(const FOwnUser &)> | Callback = {} | ) |
Create a connection to the API anonymously.
Callback | Called when a response is received from the API |
void UStreamChatClientComponent::ConnectGuestUser | ( | const FUser & | User, |
const UObject * | WorldContextObject, | ||
FLatentActionInfo | LatentInfo, | ||
FOwnUser & | OutUser | ||
) |
Create a connection to the API by creating a guest account
User | Generally only the user id is required |
OutUser | Guest user info |
void UStreamChatClientComponent::ConnectGuestUser | ( | const FUser & | User, |
TFunction< void(const FOwnUser &)> | Callback = {} |
||
) |
Create a connection to the API by creating a guest account.
User | Generally only the user id is required |
Callback | Called when a response is received from the API |
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.
User | Generally only the user id is required |
Token | A JWT token for the given user |
OutUser | Latest info of the logged in user |
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.
User | Generally only the user id is required |
Token | A JWT token for the given user |
Callback | Called when a response is received from the API |
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.
User | Generally only the user id is required |
TokenProvider | Can be used to asynchronously generate tokens from your own backend |
Callback | Called when a response is received from the API |
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).
ChannelProperties | Properties of the channel to create |
Callback | Called when a response is received from the API |
void UStreamChatClientComponent::FlagMessage | ( | const FMessage & | Message | ) | const |
Flag message for moderation.
Message | A reference to an existing message |
void UStreamChatClientComponent::FlagUser | ( | const FUserRef & | User | ) | const |
Flag user for moderation.
User | A reference to a user |
void UStreamChatClientComponent::ListDevices | ( | TFunction< void(TArray< FDevice >)> | Callback | ) | const |
Returns a list of all available devices.
Callback | Called when response is received |
void UStreamChatClientComponent::MuteUserBP | ( | const FUserRef & | User, |
FTimespan | Timeout | ||
) | const |
Mute the given user.
Timeout | Timeout of ban. User will be unbanned after this period of time (unlimited if zero) |
User | A reference to a user |
TEnableIf< TIsInvocable< FunctorType, constTEvent &, VarTypes... >::Value, FDelegateHandle >::Type UStreamChatClientComponent::On | ( | FunctorType && | Functor, |
VarTypes... | Vars | ||
) |
Subscribe to a client 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 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.
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 UStreamChatClientComponent::On | ( | UserClass * | Obj, |
TEventDelegateUObjectMethodPtr< TEvent, UserClass > | Method | ||
) |
Subscribe to a client 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 UStreamChatClientComponent::QueryAdditionalChannels | ( | int32 | Limit = 10 , |
TFunction< void()> | Callback = {} |
||
) |
Fetch more channels from the server.
Limit | Number of channels returned is limited by this value. Maximum 30. |
Callback | Called when a response is received from the backend |
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.
Filter | Conditions to use to filter the banned users |
SortOptions | The sorting used for the banned users matching the filters. Sorting is based on field and direction, multiple sorting options can be provided. |
PaginationOptions | Pagination for bans can be done in two ways: using offset/limit or using the "created_at" field. |
Callback | Called when response is received. |
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.
Flags | Get state, get presence and/or watch |
ChannelProperties | Properties of the channel to query |
Callback | Called when a response is received from the API |
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.
Filter | The 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] } } |
SortOptions | The sorting used for the channels matching the filters. Sorting is based on field and direction, and multiple sorting options can be provided. |
Flags | Get state, get presence and/or watch |
OutChannels | An array of channel objects which can be used to interact with the channels |
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.
Callback | Called when a response is received from the API |
Filter | The 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] } } |
SortOptions | The sorting used for the channels matching the filters. Sorting is based on field and direction, and multiple sorting options can be provided. |
Flags | Get state, get presence and/or watch |
PaginationOptions | Pagination offset and limit |
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.
bPresence | Get updates when the user goes offline/online |
Filter | Conditions to use to filter the users, |
Sort | The sorting used for the users matching the filters. Sorting is based on field and direction, multiple sorting options can be provided. |
PaginationOptions | The number of users to return and pagination offset |
Callback | Called when response is received |
void UStreamChatClientComponent::RemoveDevice | ( | const FString & | DeviceId | ) | const |
Unregistering a device removes the device from the user and stops further new message notifications.
DeviceId | Device-specific identifier |
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.
Callback | Called when response is received |
Query | Search phrase |
ChannelFilter | Channel filter conditions |
MessageFilter | Message filter conditions |
Sort | Sort parameters. Cannot be used with non-zero offset. |
MessageLimit | Number of messages to return |
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.
User | User to ban |
Timeout | Timeout of ban. User will be unbanned after this period of time (unlimited if zero) |
void UStreamChatClientComponent::ShadowUnbanUser | ( | const FUserRef & | User | ) | const |
Remove previously applied app-wide shadow ban.
User | User to unban |
void UStreamChatClientComponent::UnbanUser | ( | const FUserRef & | User | ) | const |
Remove previously applied app-wide ban.
User | User to unban |
void UStreamChatClientComponent::UnmuteUser | ( | const FUserRef & | User | ) | const |
Unmute a previously muted user.
User | A reference to a user |
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
ChannelProperties | Properties of the channel to watch |
OutChannel | Object which can be used to interact with the channel |
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.
ChannelProperties | Properties of the channel to watch |
Callback | Called when a response is received from the API |