Skip to content

Commit

Permalink
Implement onAdd/onRemove script callback for vitcPacketReceiveNotific…
Browse files Browse the repository at this point in the history
…ationObject.
  • Loading branch information
fr1tz committed Feb 5, 2016
1 parent b5f2f6a commit 93d7856
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Engine/source/VITC/net/vitcPacketReceiveNotificationObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

IMPLEMENT_CONOBJECT(vitcPacketReceiveNotificationObject);

IMPLEMENT_CALLBACK(vitcPacketReceiveNotificationObject, onAdd, void, (), (),
"Called when the object is registered with the system after the object has been created.");
IMPLEMENT_CALLBACK(vitcPacketReceiveNotificationObject, onRemove, void, (), (),
"Called when the object is removed from the system before it is deleted.");
IMPLEMENT_CALLBACK(vitcPacketReceiveNotificationObject, onPacketReceive, void, (const char* address, const char* base64data), (address, base64data),
"@brief Called whenever a packet has been received.\n\n"
"@param address Packet source address.\n"
Expand All @@ -35,7 +39,7 @@ bool vitcPacketReceiveNotificationObject::onAdd()
if(!Parent::onAdd())
return false;

const char *name = getName();
const char *name = this->getName();

if(name && name[0] && getClassRep())
{
Expand All @@ -44,9 +48,20 @@ bool vitcPacketReceiveNotificationObject::onAdd()
mNameSpace = Con::lookupNamespace(name);
}

// Notify Script.
onAdd_callback();

return true;
}

void vitcPacketReceiveNotificationObject::onRemove()
{
// Notify Script.
onRemove_callback();

Parent::onRemove();
}

void vitcPacketReceiveNotificationObject::processPacketReceiveEvent(NetAddress srcAddress, RawData packetData)
{
char addrBuf[256];
Expand Down
3 changes: 3 additions & 0 deletions Engine/source/VITC/net/vitcPacketReceiveNotificationObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class vitcPacketReceiveNotificationObject : public SimObject
{
public:
DECLARE_CALLBACK(void, onAdd, ());
DECLARE_CALLBACK(void, onRemove, ());
DECLARE_CALLBACK(void, onPacketReceive, (const char* address, const char* base64data));

protected:
Expand All @@ -25,6 +27,7 @@ class vitcPacketReceiveNotificationObject : public SimObject
void processPacketReceiveEvent(NetAddress srcAddress, RawData packetData);

bool onAdd();
void onRemove();

DECLARE_CONOBJECT(vitcPacketReceiveNotificationObject);
};
Expand Down

0 comments on commit 93d7856

Please sign in to comment.