[+] Connect/Disconnect callbacks

This commit is contained in:
Reece Wilson 2023-12-16 19:56:10 +00:00
parent aa7591967a
commit bb3a872b07
2 changed files with 16 additions and 1 deletions

View File

@ -123,7 +123,9 @@ AUI_INTERFACE(AuIRPCChannelCallbacks,
AUI_INTERFACE(AuIRPCServerCallbacks,
AUI_METHOD(void, OnMessage, (AuSPtr<AuIRPCSession>, pClient,
AuByteBuffer &, refReadOnly))
AuByteBuffer &, refReadOnly)),
AUI_METHOD(void, OnConnect, (AuSPtr<AuIRPCSession>, pClient)),
AUI_METHOD(void, OnDisconnect, (AuSPtr<AuIRPCSession>, pClient))
);
struct AuIRPCRequest

View File

@ -61,6 +61,14 @@ void AuRPCServerChannel::OnDisconnect(bool error)
void AuRPCServerChannel::RemoveFromParent()
{
if (auto pCallbacks = this->server_->pCallbacks)
{
if (!this->isTempChannel_)
{
pCallbacks->OnDisconnect(this->SharedFromThis());
}
}
if (auto pParent = this->server_)
{
AU_LOCK_GUARD(pParent->lock->AsWritable());
@ -193,6 +201,11 @@ void AuRPCServerChannel::SendConnectOK()
res->FinalizeWrite();
this->SendResponse(res);
if (auto pCallbacks = this->server_->pCallbacks)
{
pCallbacks->OnConnect(this->SharedFromThis());
}
}
void AuRPCServerChannel::SendToNewChannel()