Group を TCP か UDP クライアントを使ってセットアップする

Group では人数の制限なくクライアント同士で同期を取ることが可能です。

Diarkis Group はネットワークプロトコルに依存しませんが、ネットワーククライアントを渡す必要があります。ここでは、TCP または UDP クライアントを持つ Diarkis Group のインスタンスを設定する方法を説明します。

TCP クライアントを使ったセットアップ

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); });

UDP クライアントを使ったセットアップ

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); });