Diarkis C++Client Library API Document
Diarkis::Modules::IDiarkisGroup Class Referenceabstract

Interface class for Group. More...

#include <group.h>

Public Member Functions

virtual ~IDiarkisGroup ()
 Destructor for the IDiarkisGroup class. More...
 
virtual void SetLoggerFactory (const std::shared_ptr< IDiarkisLoggerFactory > &loggerFactory, Diarkis::StdString loggerNameSuffix)=0
 Register a logger. More...
 
virtual bool SetupAsTcp (const std::shared_ptr< IDiarkisTcp > &tcp)=0
 Set up Group as a TCP protocol. More...
 
virtual bool SetupAsUdp (const std::shared_ptr< IDiarkisUdp > &udp)=0
 Set up Group as a UDP protocol. More...
 
virtual bool SetTcp (const std::shared_ptr< IDiarkisTcp > &tcp)=0
 Registers a pointer to the IDiarkisTcp class. More...
 
virtual bool SetUdp (const std::shared_ptr< IDiarkisUdp > &udp)=0
 Registers a pointer to the IDiarkisUdp class. More...
 
virtual std::shared_ptr< IDiarkisEvent< const DiarkisGroupEventArgs & > > GetCreateEvent ()=0
 Get the callback event called when a Group is created. More...
 
virtual std::shared_ptr< IDiarkisEvent< const DiarkisGroupEventArgs & > > GetJoinEvent ()=0
 Get the callback event called when joined a Group. More...
 
virtual std::shared_ptr< IDiarkisEvent< const DiarkisGroupEventArgs & > > GetLeaveEvent ()=0
 Get the callback event called when left from a Group. More...
 
virtual std::shared_ptr< IDiarkisEvent< const DiarkisPayloadEventArgs & > > GetMemberJoinEvent ()=0
 Get the callback event called when other clients joined a Group. More...
 
virtual std::shared_ptr< IDiarkisEvent< const DiarkisPayloadEventArgs & > > GetMemberLeaveEvent ()=0
 Get the callback event called when other clients left from a Group. More...
 
virtual std::shared_ptr< IDiarkisEvent< const DiarkisPayloadEventArgs & > > GetMemberBroadcastEvent ()=0
 Get the callback event called when received a broadcast message. More...
 
virtual void GetGroupIDs (Diarkis::StdVector< Diarkis::StdString > &idList)=0
 Get a list of Group member's user IDs. More...
 
virtual Diarkis::System::Result Create (bool allowEmpty, bool join, uint16_t ttl)=0
 Creates a new Group. More...
 
virtual Diarkis::System::Result Join (const char *groupID, const uint8_t *message, size_t messageSize)=0
 Join an existing Group. More...
 
virtual Diarkis::System::Result Join (const Diarkis::StdString &groupID, const Diarkis::StdVector< uint8_t > &message)=0
 Same as Join() More...
 
virtual Diarkis::System::Result JoinRandom (uint16_t ttl, const uint8_t *message, size_t messageSize, uint32_t interval=200, bool allowEmpty=false)=0
 If there is a Group you can join, join that Group, otherwise create a new Group. More...
 
virtual Diarkis::System::Result JoinRandom (uint16_t ttl, const Diarkis::StdVector< uint8_t > &message, uint32_t interval=200, bool allowEmpty=false)=0
 Same as JoinRandom() More...
 
virtual Diarkis::System::Result Leave (const char *groupID, const uint8_t *message, size_t messageSize)=0
 Leave from the Group. More...
 
virtual Diarkis::System::Result Leave (const Diarkis::StdString &groupID, const Diarkis::StdVector< uint8_t > &message)=0
 Same as Leave() More...
 
virtual Diarkis::System::Result BroadcastTo (const char *groupID, const uint8_t *message, size_t messageSize, bool reliable=true)=0
 Sends a message to all participants of the Group. More...
 
virtual Diarkis::System::Result BroadcastTo (const Diarkis::StdString &groupID, const Diarkis::StdVector< uint8_t > &message, bool reliable=true)=0
 Same as BroadcastTo() More...
 

Detailed Description

Interface class for Group.

Functions and callback events are provided to use Group.

Constructor & Destructor Documentation

◆ ~IDiarkisGroup()

virtual Diarkis::Modules::IDiarkisGroup::~IDiarkisGroup ( )
inlinevirtual

Destructor for the IDiarkisGroup class.

Member Function Documentation

◆ SetLoggerFactory()

virtual void Diarkis::Modules::IDiarkisGroup::SetLoggerFactory ( const std::shared_ptr< IDiarkisLoggerFactory > &  loggerFactory,
Diarkis::StdString  loggerNameSuffix 
)
pure virtual

Register a logger.

Parameters
[in]loggerFactoryPointer to IDiarkisLoggerFactory
[in]loggerNameSuffixString to be added to the tag that will be output to the log

◆ SetupAsTcp()

virtual bool Diarkis::Modules::IDiarkisGroup::SetupAsTcp ( const std::shared_ptr< IDiarkisTcp > &  tcp)
pure virtual

Set up Group as a TCP protocol.

◆ SetupAsUdp()

virtual bool Diarkis::Modules::IDiarkisGroup::SetupAsUdp ( const std::shared_ptr< IDiarkisUdp > &  udp)
pure virtual

Set up Group as a UDP protocol.

◆ SetTcp()

virtual bool Diarkis::Modules::IDiarkisGroup::SetTcp ( const std::shared_ptr< IDiarkisTcp > &  tcp)
pure virtual

Registers a pointer to the IDiarkisTcp class.

Parameters
[in]tcpPointer to IDiarkisTcp class

◆ SetUdp()

virtual bool Diarkis::Modules::IDiarkisGroup::SetUdp ( const std::shared_ptr< IDiarkisUdp > &  udp)
pure virtual

Registers a pointer to the IDiarkisUdp class.

Parameters
[in]udpPointer to IDiarkisUdp class

◆ GetCreateEvent()

virtual std::shared_ptr<IDiarkisEvent<const DiarkisGroupEventArgs&> > Diarkis::Modules::IDiarkisGroup::GetCreateEvent ( )
pure virtual

Get the callback event called when a Group is created.

◆ GetJoinEvent()

virtual std::shared_ptr<IDiarkisEvent<const DiarkisGroupEventArgs&> > Diarkis::Modules::IDiarkisGroup::GetJoinEvent ( )
pure virtual

Get the callback event called when joined a Group.

◆ GetLeaveEvent()

virtual std::shared_ptr<IDiarkisEvent<const DiarkisGroupEventArgs&> > Diarkis::Modules::IDiarkisGroup::GetLeaveEvent ( )
pure virtual

Get the callback event called when left from a Group.

◆ GetMemberJoinEvent()

virtual std::shared_ptr<IDiarkisEvent<const DiarkisPayloadEventArgs&> > Diarkis::Modules::IDiarkisGroup::GetMemberJoinEvent ( )
pure virtual

Get the callback event called when other clients joined a Group.

◆ GetMemberLeaveEvent()

virtual std::shared_ptr<IDiarkisEvent<const DiarkisPayloadEventArgs&> > Diarkis::Modules::IDiarkisGroup::GetMemberLeaveEvent ( )
pure virtual

Get the callback event called when other clients left from a Group.

◆ GetMemberBroadcastEvent()

virtual std::shared_ptr<IDiarkisEvent<const DiarkisPayloadEventArgs&> > Diarkis::Modules::IDiarkisGroup::GetMemberBroadcastEvent ( )
pure virtual

Get the callback event called when received a broadcast message.

◆ GetGroupIDs()

virtual void Diarkis::Modules::IDiarkisGroup::GetGroupIDs ( Diarkis::StdVector< Diarkis::StdString > &  idList)
pure virtual

Get a list of Group member's user IDs.

◆ Create()

virtual Diarkis::System::Result Diarkis::Modules::IDiarkisGroup::Create ( bool  allowEmpty,
bool  join,
uint16_t  ttl 
)
pure 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.

◆ Join() [1/2]

virtual Diarkis::System::Result Diarkis::Modules::IDiarkisGroup::Join ( const char *  groupID,
const uint8_t *  message,
size_t  messageSize 
)
pure 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

◆ Join() [2/2]

virtual Diarkis::System::Result Diarkis::Modules::IDiarkisGroup::Join ( const Diarkis::StdString groupID,
const Diarkis::StdVector< uint8_t > &  message 
)
pure virtual

Same as Join()

◆ JoinRandom() [1/2]

virtual Diarkis::System::Result Diarkis::Modules::IDiarkisGroup::JoinRandom ( uint16_t  ttl,
const uint8_t *  message,
size_t  messageSize,
uint32_t  interval = 200,
bool  allowEmpty = false 
)
pure 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.

◆ JoinRandom() [2/2]

virtual Diarkis::System::Result Diarkis::Modules::IDiarkisGroup::JoinRandom ( uint16_t  ttl,
const Diarkis::StdVector< uint8_t > &  message,
uint32_t  interval = 200,
bool  allowEmpty = false 
)
pure virtual

Same as JoinRandom()

◆ Leave() [1/2]

virtual Diarkis::System::Result Diarkis::Modules::IDiarkisGroup::Leave ( const char *  groupID,
const uint8_t *  message,
size_t  messageSize 
)
pure virtual

Leave from the 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

◆ Leave() [2/2]

virtual Diarkis::System::Result Diarkis::Modules::IDiarkisGroup::Leave ( const Diarkis::StdString groupID,
const Diarkis::StdVector< uint8_t > &  message 
)
pure virtual

Same as Leave()

◆ BroadcastTo() [1/2]

virtual Diarkis::System::Result Diarkis::Modules::IDiarkisGroup::BroadcastTo ( const char *  groupID,
const uint8_t *  message,
size_t  messageSize,
bool  reliable = true 
)
pure virtual

Sends a message to all participants of the 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
[in]messageMessage to be sent
[in]messageSizeLength of the message
[in]reliableDetermines if the message is sent via reliable communication (RUDP); ignored for TCP protocol.

◆ BroadcastTo() [2/2]

virtual Diarkis::System::Result Diarkis::Modules::IDiarkisGroup::BroadcastTo ( const Diarkis::StdString groupID,
const Diarkis::StdVector< uint8_t > &  message,
bool  reliable = true 
)
pure virtual

Same as BroadcastTo()


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