Diarkis C++Client Library API Document
DiarkisGroupBase Class Reference

Base class that wraps the IDiarkisGroup class for easy use of Group functionality. More...

#include <DiarkisGroupBase.h>

Collaboration diagram for DiarkisGroupBase:

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< IDiarkisTcptcp_
 Pointer to the IDiarkisTcp class. More...
 
std::shared_ptr< IDiarkisUdpudp_
 Pointer to the IDiarkisUdp class. More...
 
std::shared_ptr< IDiarkisGroupgroup_
 Pointer to the IDiarkisGroup class. More...
 
std::shared_ptr< IDiarkisLoggerlogger_
 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...
 

Detailed Description

Base class that wraps the IDiarkisGroup class for easy use of Group functionality.

Constructor & Destructor Documentation

◆ DiarkisGroupBase()

DiarkisGroupBase::DiarkisGroupBase ( )

DiarkisGroupBase constructor.

Here is the call graph for this function:

◆ ~DiarkisGroupBase()

DiarkisGroupBase::~DiarkisGroupBase ( )
virtual

DiarkisGroupBase destructor.

Member Function Documentation

◆ SetupTcpGroup()

void DiarkisGroupBase::SetupTcpGroup ( const std::shared_ptr< IDiarkisTcp > &  tcp,
const std::shared_ptr< LoggerFactory > &  loggerFactory,
bool  bRetry 
)
virtual

Set up Group with TCP protocol.

Register loggers and callback functions.

Parameters
[in]tcpPointer to IDiarkisTcp class
[in]loggerFactoryPointer to LoggerFactory class
[in]bRetryCall this function with true when reconnecting after a failed attempt to join a group. The first call to this function must be false.
Here is the call graph for this function:

◆ SetupUdpGroup()

void DiarkisGroupBase::SetupUdpGroup ( const std::shared_ptr< IDiarkisUdp > &  udp,
const std::shared_ptr< LoggerFactory > &  loggerFactory,
bool  bRetry 
)
virtual

Set up Group with UDP protocol.

Register loggers and callback functions.

Parameters
[in]udpPointer to IDiarkisUdp class
[in]loggerFactoryPointer to logger class
[in]bRetryCall this function with true when reconnecting after a failed attempt to join a group. The first call to this function must be false.
Here is the call graph for this function:

◆ SendCreateGroup()

void DiarkisGroupBase::SendCreateGroup ( bool  allowEmpty,
bool  join,
uint16_t  ttl 
)
virtual

Creates a new group.

Callback events registered with GetCreateEvent() (e.g. OnGroupCreation) will be triggered.

Parameters
[in]allowEmptyDetermines 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]joinDetermines 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]ttlSpecifies the duration, in seconds, of a group's existence after it becomes empty; used only if allowEmpty is set to true.
Here is the call graph for this function:

◆ SendJoinGroup() [1/2]

void DiarkisGroupBase::SendJoinGroup ( const char *  groupID,
const uint8_t *  message,
size_t  messageSize 
)
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.

Parameters
[in]groupIDID of the group to join
[in]messageSends 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]messageSizeLength of the message
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendJoinGroup() [2/2]

void DiarkisGroupBase::SendJoinGroup ( const std::string &  groupID,
const std::vector< uint8_t > &  message 
)
virtual

Same as SendJoingGroup()

Here is the call graph for this function:

◆ SendRandomJoinGroup() [1/2]

void DiarkisGroupBase::SendRandomJoinGroup ( uint16_t  ttl,
const uint8_t *  message,
size_t  messageSize,
uint32_t  interval,
bool  allowEmpty = false 
)
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.

Parameters
[in]ttlDuration in seconds since the group became empty, used only when allowEmpty is set to true.
[in]messageSends an optional message to group members when they join.
[in]messageSizeLength of the message
[in]intervalSpecifies 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]allowEmptyDetermines 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendRandomJoinGroup() [2/2]

void DiarkisGroupBase::SendRandomJoinGroup ( uint16_t  ttl,
const std::vector< uint8_t > &  message,
uint32_t  interval,
bool  allowEmpty = false 
)
virtual

Same as SendRandomJoinGroup()

Here is the call graph for this function:

◆ SendLeaveGroup() [1/4]

void DiarkisGroupBase::SendLeaveGroup ( const char *  groupID,
const uint8_t *  message,
size_t  messageSize 
)
virtual

Leave from the specified group.

Callback event registered with GetMemberLeaveEvent() (e.g. OnGroupMemberLeave) will be triggered.

Parameters
[in]groupIDID of the group to leave
[in]messageSends an message to group members when leaving.
[in]messageSizeLength of the message
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendLeaveGroup() [2/4]

void DiarkisGroupBase::SendLeaveGroup ( const std::string &  groupID,
const std::vector< uint8_t > &  message 
)
virtual

Same as SendLeaveGroup(const char*, const uint8_t*, size_t)

Here is the call graph for this function:

◆ SendLeaveGroup() [3/4]

void DiarkisGroupBase::SendLeaveGroup ( const uint8_t *  message,
size_t  messageSize 
)
virtual

Leave from all groups.

Callback event registered with GetMemberLeaveEvent() (e.g. OnGroupMemberLeave) will be triggered.

Parameters
[in]messageSends an message to group members when leaving.
[in]messageSizeLength of the message
Here is the call graph for this function:

◆ SendLeaveGroup() [4/4]

void DiarkisGroupBase::SendLeaveGroup ( const std::vector< uint8_t > &  message)
virtual

Same as SendLeaveGroup(const uint8_t*, size_t)

Here is the call graph for this function:

◆ SendBroadcastToGroup() [1/4]

void DiarkisGroupBase::SendBroadcastToGroup ( const uint8_t *  payload,
size_t  payloadSize,
bool  reliable 
)
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.

Parameters
[in]payloadMessage to be sent
[in]payloadSizeLength of the payload
[in]reliableDetermines if the message is sent via reliable communication (RUDP); ignored for TCP protocol.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendBroadcastToGroup() [2/4]

void DiarkisGroupBase::SendBroadcastToGroup ( const std::vector< uint8_t > &  payload,
bool  reliable 
)
virtual

Same as SendBroadcastToGroup(const uint8_t*, size_t, bool)

Here is the call graph for this function:

◆ SendBroadcastToGroup() [3/4]

void DiarkisGroupBase::SendBroadcastToGroup ( const char *  groupID,
const uint8_t *  payload,
size_t  payloadSize,
bool  reliable 
)
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.

Parameters
[in]groupIDID of the group to send a message
[in]payloadMessage to be sent
[in]payloadSizeLength of the payload
[in]reliableDetermines if the message is sent via reliable communication (RUDP); ignored for TCP protocol.
Here is the call graph for this function:

◆ SendBroadcastToGroup() [4/4]

void DiarkisGroupBase::SendBroadcastToGroup ( const std::string &  groupID,
const std::vector< uint8_t > &  payload,
bool  reliable 
)
virtual

Same as SendBroadcastToGroup(const char*, const uint8_t*, size_t, bool)

Here is the call graph for this function:

◆ IsJoin()

bool DiarkisGroupBase::IsJoin ( )

Whether or not you are participating in a group.

◆ IsFail()

bool DiarkisGroupBase::IsFail ( )

Whether or not you failed to join the group.

◆ GetGroupID()

Diarkis::StdString DiarkisGroupBase::GetGroupID ( )

Retrieve the Group ID of the participating group.

◆ OnGroupCreation()

void DiarkisGroupBase::OnGroupCreation ( DiarkisTransportType  transportType,
const DiarkisGroupEventArgs e 
)
protectedvirtual

Callback function called when a group is created.

Called when a Group Create response is received from the server.

Here is the call graph for this function:

◆ OnGroupJoin()

void DiarkisGroupBase::OnGroupJoin ( DiarkisTransportType  transportType,
const DiarkisGroupEventArgs e 
)
protectedvirtual

Callback function called when joining a group.

Called when a Group Join response is received from the server.

Here is the call graph for this function:

◆ OnGroupLeave()

void DiarkisGroupBase::OnGroupLeave ( DiarkisTransportType  transportType,
const DiarkisGroupEventArgs e 
)
protectedvirtual

Callback function called when leaving a group.

Called when a Group Leave response is received from the server.

Here is the call graph for this function:

◆ OnGroupMemberJoin()

void DiarkisGroupBase::OnGroupMemberJoin ( DiarkisTransportType  transportType,
const DiarkisPayloadEventArgs e 
)
protectedvirtual

Callback function called when another member joins the group.

Called when a Group Join notification is received from the server.

Here is the call graph for this function:

◆ OnGroupMemberLeave()

void DiarkisGroupBase::OnGroupMemberLeave ( DiarkisTransportType  transportType,
const DiarkisPayloadEventArgs e 
)
protectedvirtual

Callback function called when another member leaves the group.

Called when a Group Leave notification is received from the server.

Here is the call graph for this function:

◆ OnGroupMemberBroadcast()

void DiarkisGroupBase::OnGroupMemberBroadcast ( DiarkisTransportType  transportType,
const DiarkisPayloadEventArgs e 
)
protectedvirtual

Callback function called when a broadcast message is received.

Called when a Group Broadcast notification is received from the server.

Here is the call graph for this function:

Member Data Documentation

◆ tcp_

std::shared_ptr<IDiarkisTcp> DiarkisGroupBase::tcp_
protected

Pointer to the IDiarkisTcp class.

◆ udp_

std::shared_ptr<IDiarkisUdp> DiarkisGroupBase::udp_
protected

Pointer to the IDiarkisUdp class.

◆ group_

std::shared_ptr<IDiarkisGroup> DiarkisGroupBase::group_
protected

Pointer to the IDiarkisGroup class.

◆ logger_

std::shared_ptr<IDiarkisLogger> DiarkisGroupBase::logger_
protected

Pointer to the IDiarkisLogger class.

◆ eventUnsubscriptions_

Diarkis::StdVector<std::function<void()> > DiarkisGroupBase::eventUnsubscriptions_
protected

Lambda functions list.

◆ groupID_

Diarkis::StdString DiarkisGroupBase::groupID_
protected

Group ID.

◆ groupMessage_

Diarkis::StdString DiarkisGroupBase::groupMessage_
protected

Latest message received.

◆ messageFromUid_

Diarkis::StdString DiarkisGroupBase::messageFromUid_
protected

User ID of the sender of the most recent message received.

◆ groupConnect_

ConnectState DiarkisGroupBase::groupConnect_
protected

Group connection status.


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