Skip to content

Commit

Permalink
clientStateMap: keeping a map of clientStateMap
Browse files Browse the repository at this point in the history
FYI, this might not be needed.

Signed-off-by: Noor Azura Ahmad Tarmizi <[email protected]>
  • Loading branch information
AzuraTarmiziIntel committed May 17, 2024
1 parent 3192313 commit 25e6084
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions jclklib/client/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ bool JClkLibClientApi::jcl_connect()

appClientState.set_clientID(newClientID);

/* Add in the map */
clientStateMap.insert(std::pair<JClkLibCommon::sessionId_t,ClientState*>\
(appClientState.get_sessionId(),&appClientState));

return true;
}

Expand Down Expand Up @@ -158,6 +162,7 @@ bool JClkLibClientApi::jcl_subscribe(JClkLibCommon::jcl_subscription &newSub,

bool JClkLibClientApi::jcl_disconnect()
{
std::map <JClkLibCommon::sessionId_t, JClkLibClient::ClientState*>::iterator it;
bool retVal = false;

// Send a disconnect message
Expand All @@ -175,6 +180,13 @@ bool JClkLibClientApi::jcl_disconnect()
/* delete the ClientState reference inside ClientNotificationMessage class */
ClientNotificationMessage::deleteClientState(&appClientState);

it = clientStateMap.find(appClientState.get_sessionId());

if (it != clientStateMap.end()) {
delete it->second;
clientStateMap.erase(it);
}

retVal = true;

done:
Expand Down
2 changes: 1 addition & 1 deletion jclklib/client/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace JClkLibClient {
class JClkLibClientApi {
private :
//std::map<PortIdentity_t, port_info> ports;
static std::map <JClkLibCommon::sessionId_t, ClientState> clientStateMap;
inline static std::map <JClkLibCommon::sessionId_t, ClientState*> clientStateMap;
ClientState appClientState;
public :
JClkLibClientApi() {
Expand Down

0 comments on commit 25e6084

Please sign in to comment.