Setting Up Group With TCP Or UDP Client

Diarkis Group allows unlimited number of clients to communicate in realtime.

Diarkis Group is network protocol agnostic, but it needs to have a network client passed to it.

We will explain how to set up a room module instance with TCP or UDP client.

Setting Up Group With TCP Client

shared_ptr<IDiarkisGroup> group = shared_ptr<IDiarkisGroup>(DiarkisCreateGroup());

// This is how you pass a Diarkis TCP client class instance
group->SetupAsTcp(diarkisTcpClient);

// Setting up the event listener callbacks

// This event is raised when you create a new group
REG_EVENT(group->GetCreateEvent(), [this](void*, const DiarkisGroupEventArgs& e) { this->OnCreate(e); });

// This event is raised when you join a group
REG_EVENT(group->GetJoinEvent(), [this](void*, const DiarkisGroupEventArgs& e) { this->OnJoin(e); });

// This event is raised when you leave a group
REG_EVENT(group->GetLeaveEvent(), [this](void*, const DiarkisGroupEventArgs& e) { this->OnLeave(e); });

// This event is raised when a new client joins a group you have joined
REG_EVENT(group->GetMemberJoinEvent(), [this](void*, const DiarkisPayloadEventArgs& e) { this->OnMemberJoin(e); });

// This event is raised when a client leaves a group you have joined
REG_EVENT(group->GetMemberLeaveEvent(), [this](void*, const DiarkisPayloadEventArgs& e) { this->OnMemberLeave(e); });

// This event is raised when a client receives a message from another client
REG_EVENT(group->GetMemberBroadcastEvent(), [this](void*, const DiarkisPayloadEventArgs& e) { this->OnMemberBroadcast(e); });

Setting Up Group With UDP Client

shared_ptr<IDiarkisGroup> group = shared_ptr<IDiarkisGroup>(DiarkisCreateGroup());

// This is how you pass a Diarkis UDP client class instance
group->SetupAsUdp(diarkisUdpClient);

// Setting up the event listener callbacks

// This event is raised when you create a new group
REG_EVENT(group->GetCreateEvent(), [this](void*, const DiarkisGroupEventArgs& e) { this->OnCreate(e); });

// This event is raised when you join a group
REG_EVENT(group->GetJoinEvent(), [this](void*, const DiarkisGroupEventArgs& e) { this->OnJoin(e); });

// This event is raised when you leave a group
REG_EVENT(group->GetLeaveEvent(), [this](void*, const DiarkisGroupEventArgs& e) { this->OnLeave(e); });

// This event is raised when a new client joins a group you have joined
REG_EVENT(group->GetMemberJoinEvent(), [this](void*, const DiarkisPayloadEventArgs& e) { this->OnMemberJoin(e); });

// This event is raised when a client leaves a group you have joined
REG_EVENT(group->GetMemberLeaveEvent(), [this](void*, const DiarkisPayloadEventArgs& e) { this->OnMemberLeave(e); });

// This event is raised when a client receives a message from another client
REG_EVENT(group->GetMemberBroadcastEvent(), [this](void*, const DiarkisPayloadEventArgs& e) { this->OnMemberBroadcast(e); });