Room イベント - OnRoomMemberLeave

OnRoomMemberLeaveは、Room からクライアントが退室したときに呼び出されます。イベントに渡されるメッセージは、退室したクライアントから送信されたメッセージです。

DiarkisRoomBase.h

class DIARKIS_API DiarkisRoomBase
{
protected:
virtual void OnRoomCreation(const DiarkisRoomCreationEventArgs& e);
virtual void OnRoomJoin(const DiarkisRoomJoinEventArgs& e);
virtual void OnRoomLeave(const DiarkisRoomSuccessEventArgs& e);
virtual void OnRoomMemberJoin(const DiarkisPayloadEventArgs& e);
virtual void OnRoomMemberLeave(const DiarkisPayloadEventArgs& e);
virtual void OnRoomUpdateProperties(const DiarkisRoomSuccessEventArgs& e);
virtual void OnRoomGetProperties(const DiarkisRoomPropertiesEventArgs& e);
virtual void OnRoomMemberBroadcast(const DiarkisPayloadEventArgs& e);
virtual void OnRoomRegister(const DiarkisRoomPayloadEventArgs& e);
virtual void OnRoomFineByType(const DiarkisRoomFindByTypeEventArgs& e);

std::vector<std::function<void()>> eventUnsubscriptions;
}

DiarkisRoomBase.cpp

#define REG_EVENT(__EVENT__, __LAMBDA__) this->eventUnsubscriptions.push_back(__EVENT__->Register(__LAMBDA__))


void DiarkisRoomBase::SetupUdpRoom(std::shared_ptr<IDiarkisUdp> udp_, std::shared_ptr<LoggerFactory> loggerFactory, std::shared_ptr<ILoggerBackend> loggerBackend, bool bRetry)
{
this->room = shared_ptr<IDiarkisRoom>(DiarkisCreateRoom());

if (this->room->SetupAsUdp(udp_))
{
this->udp = udp_;
this->room->SetLoggerFactory(loggerFactory, "-UDP");
this->fileAndDebugLoggerBackend = loggerBackend;

REG_EVENT(this->room->GetCreateEvent(), [this](void*, const DiarkisRoomCreationEventArgs& e) { this->OnRoomCreation(e); });
REG_EVENT(this->room->GetJoinEvent(), [this](void*, const DiarkisRoomJoinEventArgs& e) { this->OnRoomJoin(e); });
REG_EVENT(this->room->GetLeaveEvent(), [this](void*, const DiarkisRoomSuccessEventArgs& e) { this->OnRoomLeave(e); });
REG_EVENT(this->room->GetMemberJoinEvent(), [this](void*, const DiarkisPayloadEventArgs& e) { this->OnRoomMemberJoin(e); });
REG_EVENT(this->room->GetMemberBroadcastEvent(), [this](void*, const DiarkisPayloadEventArgs& e) { this->OnRoomMemberBroadcast(e); });
REG_EVENT(this->room->GetMemberLeaveEvent(), [this](void*, const DiarkisPayloadEventArgs& e) { this->OnRoomMemberLeave(e); });

REG_EVENT(this->room->GetUpdatePropertiesEvent(), [this](void*, const DiarkisRoomSuccessEventArgs& e) { this->OnRoomUpdateProperties(e); });
REG_EVENT(this->room->GetGetPropertiesEvent(), [this](void*, const DiarkisRoomPropertiesEventArgs& e) { this->OnRoomGetProperties(e); });

REG_EVENT(this->room->GetRegisterEvent(), [this](void*, const DiarkisRoomPayloadEventArgs& e) { this->OnRoomRegister(e); });
REG_EVENT(this->room->GetFindByTypeEvnet(), [this](void*, const DiarkisRoomFindByTypeEventArgs& e) { this->OnRoomFineByType(e); });

}
}

void DiarkisRoomBase::OnRoomMemberLeave(const DiarkisPayloadEventArgs& e)
{
const vector<uint8_t> payload = e.GetPayload();
uint64_t uid = *(uint64_t*)payload.data();
}