Group に参加をする

グループに参加することで、他のメンバー・クライアントとメッセージの送受信をすることで同期をとることが可能になります。

Diarkis Group は同時に複数のグループに参加することができます。

以下の例では、グループに参加する方法と参加によるサーバからのレスポンスのハンドリング、他のクライアントがグループに参加した際に通知されるイベントの処理を示しています。

// This is the group ID that you are trying to join
string groupID = "xxxxxx";

// This is the message to be sent to other group members when you successfully join the group
const vector<uint8_t> message = groupJoinMessageData;

// This is the event listener callback for the server response when joining a group
REG_EVENT(tcpGroup->GetJoinEvent(), [this](void*, const DiarkisGroupEventArgs& e)
{
this->OnJoin(e);
});

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

group->Join(groupID, message);