![]() |
Diarkis C++Client Library API Document
|
Base class that wraps the IDiarkisGroup class for easy use of Group functionality. More...
#include <DiarkisGroupBase.h>
Public Member Functions | |
DiarkisGroupBase () | |
DiarkisGroupBase constructor. More... | |
virtual | ~DiarkisGroupBase () |
DiarkisGroupBase destructor. More... | |
virtual void | SetupTcpGroup (const std::shared_ptr< IDiarkisTcp > &tcp, const std::shared_ptr< LoggerFactory > &loggerFactory, bool bRetry) |
Set up Group with TCP protocol. More... | |
virtual void | SetupUdpGroup (const std::shared_ptr< IDiarkisUdp > &udp, const std::shared_ptr< LoggerFactory > &loggerFactory, bool bRetry) |
Set up Group with UDP protocol. More... | |
virtual void | SendCreateGroup (bool allowEmpty, bool join, uint16_t ttl) |
Creates a new group. More... | |
virtual void | SendJoinGroup (const char *groupID, const uint8_t *message, size_t messageSize) |
Join an existing group. More... | |
virtual void | SendJoinGroup (const std::string &groupID, const std::vector< uint8_t > &message) |
Same as SendJoingGroup() More... | |
virtual void | SendRandomJoinGroup (uint16_t ttl, const uint8_t *message, size_t messageSize, uint32_t interval, bool allowEmpty=false) |
If there is a group you can join, join that group, otherwise create a new group. More... | |
virtual void | SendRandomJoinGroup (uint16_t ttl, const std::vector< uint8_t > &message, uint32_t interval, bool allowEmpty=false) |
Same as SendRandomJoinGroup() More... | |
virtual void | SendLeaveGroup (const char *groupID, const uint8_t *message, size_t messageSize) |
Leave from the specified group. More... | |
virtual void | SendLeaveGroup (const std::string &groupID, const std::vector< uint8_t > &message) |
Same as SendLeaveGroup(const char*, const uint8_t*, size_t) More... | |
virtual void | SendLeaveGroup (const uint8_t *message, size_t messageSize) |
Leave from all groups. More... | |
virtual void | SendLeaveGroup (const std::vector< uint8_t > &message) |
Same as SendLeaveGroup(const uint8_t*, size_t) More... | |
virtual void | SendBroadcastToGroup (const uint8_t *payload, size_t payloadSize, bool reliable) |
Sends a broadcast to all users in all participating groups. More... | |
virtual void | SendBroadcastToGroup (const std::vector< uint8_t > &payload, bool reliable) |
Same as SendBroadcastToGroup(const uint8_t*, size_t, bool) More... | |
virtual void | SendBroadcastToGroup (const char *groupID, const uint8_t *payload, size_t payloadSize, bool reliable) |
Sends a broadcast to all users in the specified group. More... | |
virtual void | SendBroadcastToGroup (const std::string &groupID, const std::vector< uint8_t > &payload, bool reliable) |
Same as SendBroadcastToGroup(const char*, const uint8_t*, size_t, bool) More... | |
bool | IsJoin () |
Whether or not you are participating in a group. More... | |
bool | IsFail () |
Whether or not you failed to join the group. More... | |
Diarkis::StdString | GetGroupID () |
Retrieve the Group ID of the participating group. More... | |
Protected Member Functions | |
virtual void | OnGroupCreation (DiarkisTransportType transportType, const DiarkisGroupEventArgs &e) |
Callback function called when a group is created. More... | |
virtual void | OnGroupJoin (DiarkisTransportType transportType, const DiarkisGroupEventArgs &e) |
Callback function called when joining a group. More... | |
virtual void | OnGroupLeave (DiarkisTransportType transportType, const DiarkisGroupEventArgs &e) |
Callback function called when leaving a group. More... | |
virtual void | OnGroupMemberJoin (DiarkisTransportType transportType, const DiarkisPayloadEventArgs &e) |
Callback function called when another member joins the group. More... | |
virtual void | OnGroupMemberLeave (DiarkisTransportType transportType, const DiarkisPayloadEventArgs &e) |
Callback function called when another member leaves the group. More... | |
virtual void | OnGroupMemberBroadcast (DiarkisTransportType transportType, const DiarkisPayloadEventArgs &e) |
Callback function called when a broadcast message is received. More... | |
Protected Attributes | |
std::shared_ptr< IDiarkisTcp > | tcp_ |
Pointer to the IDiarkisTcp class. More... | |
std::shared_ptr< IDiarkisUdp > | udp_ |
Pointer to the IDiarkisUdp class. More... | |
std::shared_ptr< IDiarkisGroup > | group_ |
Pointer to the IDiarkisGroup class. More... | |
std::shared_ptr< IDiarkisLogger > | logger_ |
Pointer to the IDiarkisLogger class. More... | |
Diarkis::StdVector< std::function< void()> > | eventUnsubscriptions_ |
Lambda functions list. More... | |
Diarkis::StdString | groupID_ |
Group ID. More... | |
Diarkis::StdString | groupMessage_ |
Latest message received. More... | |
Diarkis::StdString | messageFromUid_ |
User ID of the sender of the most recent message received. More... | |
ConnectState | groupConnect_ |
Group connection status. More... | |
Base class that wraps the IDiarkisGroup class for easy use of Group functionality.
DiarkisGroupBase::DiarkisGroupBase | ( | ) |
|
virtual |
DiarkisGroupBase destructor.
|
virtual |
Set up Group with TCP protocol.
Register loggers and callback functions.
[in] | tcp | Pointer to IDiarkisTcp class |
[in] | loggerFactory | Pointer to LoggerFactory class |
[in] | bRetry | Call this function with true when reconnecting after a failed attempt to join a group. The first call to this function must be false. |
|
virtual |
Set up Group with UDP protocol.
Register loggers and callback functions.
[in] | udp | Pointer to IDiarkisUdp class |
[in] | loggerFactory | Pointer to logger class |
[in] | bRetry | Call this function with true when reconnecting after a failed attempt to join a group. The first call to this function must be false. |
|
virtual |
Creates a new group.
Callback events registered with GetCreateEvent() (e.g. OnGroupCreation) will be triggered.
[in] | allowEmpty | Determines if the client will keep the group even when no one has joined. true = Keep the group even when no clients are present. false = If the client is gone the group will be destroyed after the time specified by ttl has elapsed. |
[in] | join | Determines whether or not a new group is created and then joined. true = Join the group after it is created. In this case, the server will not respond to the Join request. false = Only creates the group. If you want to join the group, you need to execute Join separately. |
[in] | ttl | Specifies the duration, in seconds, of a group's existence after it becomes empty; used only if allowEmpty is set to true. |
|
virtual |
Join an existing group.
A callback event registered with GetJoinEvent() (e.g. OnGroupJoin) will be triggered.
A callback event registered with GetMemberJoinEvent() (e.g. OnGroupMemberJoin) will be triggered for the member of the target group.
[in] | groupID | ID of the group to join |
[in] | message | Sends an message to group members when join. For example, you can include a user ID to notify the user ID of a newly joined member. |
[in] | messageSize | Length of the message |
|
virtual |
Same as SendJoingGroup()
|
virtual |
If there is a group you can join, join that group, otherwise create a new group.
If you join an existing group, a callback event registered with GetJoinEvent() (e.g. OnGroupJoin) will be triggered.
When a new group is created, the callback event registered with GetCreateEvent() (e.g. OnGroupCreation ) will be triggered.
[in] | ttl | Duration in seconds since the group became empty, used only when allowEmpty is set to true. |
[in] | message | Sends an optional message to group members when they join. |
[in] | messageSize | Length of the message |
[in] | interval | Specifies the interval in milliseconds between when the server processes BroadcastTo. The default value is 200ms. The messages for the time specified by interval are compiled and sent by the server. |
[in] | allowEmpty | Determines whether or not the group is retained even when no client has joined. true = Retain the group even if no clients are present. false = The group will be destroyed after the time specified by ttl if there are no clients. |
|
virtual |
|
virtual |
Leave from the specified group.
Callback event registered with GetMemberLeaveEvent() (e.g. OnGroupMemberLeave) will be triggered.
[in] | groupID | ID of the group to leave |
[in] | message | Sends an message to group members when leaving. |
[in] | messageSize | Length of the message |
|
virtual |
Same as SendLeaveGroup(const char*, const uint8_t*, size_t)
|
virtual |
Leave from all groups.
Callback event registered with GetMemberLeaveEvent() (e.g. OnGroupMemberLeave) will be triggered.
[in] | message | Sends an message to group members when leaving. |
[in] | messageSize | Length of the message |
|
virtual |
|
virtual |
Sends a broadcast to all users in all participating groups.
The callback event registered with GetMemberBroadcastEvent() (e.g. OnGroupMemberBroadcast) will be triggered.
Callback events are also triggered for messages sent by you.
[in] | payload | Message to be sent |
[in] | payloadSize | Length of the payload |
[in] | reliable | Determines if the message is sent via reliable communication (RUDP); ignored for TCP protocol. |
|
virtual |
Same as SendBroadcastToGroup(const uint8_t*, size_t, bool)
|
virtual |
Sends a broadcast to all users in the specified group.
The callback event registered with GetMemberBroadcastEvent() (e.g. OnGroupMemberBroadcast) will be triggered.
Callback events are also triggered for messages sent by you.
[in] | groupID | ID of the group to send a message |
[in] | payload | Message to be sent |
[in] | payloadSize | Length of the payload |
[in] | reliable | Determines if the message is sent via reliable communication (RUDP); ignored for TCP protocol. |
|
virtual |
Same as SendBroadcastToGroup(const char*, const uint8_t*, size_t, bool)
bool DiarkisGroupBase::IsJoin | ( | ) |
Whether or not you are participating in a group.
bool DiarkisGroupBase::IsFail | ( | ) |
Whether or not you failed to join the group.
Diarkis::StdString DiarkisGroupBase::GetGroupID | ( | ) |
Retrieve the Group ID of the participating group.
|
protectedvirtual |
Callback function called when a group is created.
Called when a Group Create response is received from the server.
|
protectedvirtual |
Callback function called when joining a group.
Called when a Group Join response is received from the server.
|
protectedvirtual |
Callback function called when leaving a group.
Called when a Group Leave response is received from the server.
|
protectedvirtual |
Callback function called when another member joins the group.
Called when a Group Join notification is received from the server.
|
protectedvirtual |
Callback function called when another member leaves the group.
Called when a Group Leave notification is received from the server.
|
protectedvirtual |
Callback function called when a broadcast message is received.
Called when a Group Broadcast notification is received from the server.
|
protected |
Pointer to the IDiarkisTcp class.
|
protected |
Pointer to the IDiarkisUdp class.
|
protected |
Pointer to the IDiarkisGroup class.
|
protected |
Pointer to the IDiarkisLogger class.
|
protected |
Lambda functions list.
|
protected |
Group ID.
|
protected |
Latest message received.
|
protected |
User ID of the sender of the most recent message received.
|
protected |
Group connection status.