Skip to content

Commit

Permalink
Merge pull request #1415 from varumugam123/master
Browse files Browse the repository at this point in the history
Fix broken addListener() & delListener() handling.
  • Loading branch information
gladish authored Sep 19, 2018
2 parents 83d54a9 + ff57818 commit fb71123
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
4 changes: 3 additions & 1 deletion remote/rtRemoteFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ rtRemoteFunction::rtRemoteFunction(std::string const& id, std::string const& nam
, m_name(name)
, m_client(client)
, m_timeout(client->getEnvironment()->Config->environment_request_timeout())
, m_Hash(0)
{
std::hash<std::string> hashFn;
m_Hash = hashFn(name);

if (!strcmp(id.c_str(), "global"))
{
m_client->registerKeepAliveForObject(m_name);
Expand Down
25 changes: 19 additions & 6 deletions remote/rtRemoteValueWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.

#include "rtRemoteValueWriter.h"
#include "rtRemoteObject.h"
#include "rtRemoteFunction.h"
#include "rtRemoteObjectCache.h"
#include "rtRemoteConfig.h"
#include "rtRemoteMessage.h"
Expand All @@ -32,14 +33,26 @@ namespace
{
// static std::atomic<int> sNextFunctionId;

std::string getId(rtFunctionRef const& /*ref*/)
std::string getId(rtFunctionRef const& ref)
{
rtGuid id = rtGuid::newRandom();
rtFunctionCallback * obj = dynamic_cast<rtFunctionCallback *>(ref.ptr());
if(obj && !obj->getId().empty())
{
return obj->getId();
}
else
{
rtGuid id = rtGuid::newRandom();

std::stringstream ss;
ss << "func://";
ss << id.toString();
return ss.str();
std::stringstream ss;
ss << "func://";
ss << id.toString();

if(obj)
obj->setId(ss.str());

return ss.str();
}
}

std::string getId(rtObjectRef const& ref)
Expand Down
11 changes: 11 additions & 0 deletions src/rtObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <string.h>
#include <vector>
#include <string>

// rtIObject and rtIFunction are designed to be an
// Abstract Binary Interface(ABI)
Expand Down Expand Up @@ -632,11 +633,21 @@ class rtFunctionCallback: public rtIFunction
mContext = NULL;
}

void setId(std::string id)
{
mId = id;
}

std::string getId()
{
return mId;
}

private:
rtFunctionCB mCB;
void* mContext;
rtAtomic mRefCount;
std::string mId;
};


Expand Down

0 comments on commit fb71123

Please sign in to comment.