Skip to content

Commit

Permalink
move callback to service method
Browse files Browse the repository at this point in the history
  • Loading branch information
zerotacg committed Jun 26, 2024
1 parent c55cc9e commit 8fe1b01
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
15 changes: 0 additions & 15 deletions nelns/naming_service/nelns/naming_service/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,21 +405,6 @@ void cbACKUnregistration(CMessage &msgin, TSockId from, CCallbackNetBase &netbas
}
}

/**
* Callback for service registration when the naming service goes down and up (don't need to broadcast)
*/
void cbResendRegisteration(CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
{
string name;
vector<CInetAddress> addr;
TServiceId sid;
msgin.serial(name);
msgin.serialCont(addr);
msgin.serial(sid);

doRegister(name, addr, sid, from, netbase, true);
}

/**
* Callback for service unregistration.
*
Expand Down
15 changes: 14 additions & 1 deletion nelns/naming_service/nelns/naming_service/naming_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void CNamingService::init()

TCallbackItem CallbackArray[] = {
{ "RG", [=](auto &msgin, auto from, auto &netbase) { cbRegister(msgin, from); } },
{ "RRG", cbResendRegisteration },
{ "RRG", [=](auto &msgin, auto from, auto &netbase) { cbResendRegisteration(msgin, from); } },
{ "QP", cbQueryPort },
{ "UNI", cbUnregisterSId },
{ "ACK_UNI", cbACKUnregistration },
Expand Down Expand Up @@ -139,3 +139,16 @@ void CNamingService::cbRegister(CMessage &msgin, TSockId from)

doRegister(name, addr, sid, from, *CallbackServer);
}

void CNamingService::cbResendRegisteration(CMessage &msgin, TSockId from)
{
string name;
vector<CInetAddress> addr;
TServiceId sid;
msgin.serial(name);
msgin.serialCont(addr);
msgin.serial(sid);

doRegister(name, addr, sid, from, *CallbackServer, true);
}

5 changes: 5 additions & 0 deletions nelns/naming_service/nelns/naming_service/naming_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class CNamingService : public NLNET::IService
*/
void cbRegister(NLNET::CMessage &msgin, NLNET::TSockId from);

/**
* Callback for service registration when the naming service goes down and up (don't need to broadcast)
*/
void cbResendRegisteration(NLNET::CMessage &msgin, NLNET::TSockId from);

/// Service instance manager singleton
CServiceInstanceManager _ServiceInstances;
};
Expand Down
1 change: 1 addition & 0 deletions nelns/naming_service/tests/naming_service.it.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ TEST_F(CNamingServiceIT, shouldUpdateServiceRegistry)
client.send(msgout);
client.flush();
namingService.update();
client.update2(-1, 200);

EXPECT_THAT(
RegisteredServices,
Expand Down

0 comments on commit 8fe1b01

Please sign in to comment.