mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5939 from dumganhar/merge5923
Merge PR #5923: implement fireEventToScript method to integrate JSB event handling with the original native code
This commit is contained in:
commit
ec4b1ee485
|
@ -567,6 +567,8 @@ void SIOClient::fireEvent(const std::string& eventName, const std::string& data)
|
||||||
{
|
{
|
||||||
log("SIOClient::fireEvent called with event name: %s and data: %s", eventName.c_str(), data.c_str());
|
log("SIOClient::fireEvent called with event name: %s and data: %s", eventName.c_str(), data.c_str());
|
||||||
|
|
||||||
|
_delegate->fireEventToScript(this, eventName, data);
|
||||||
|
|
||||||
if(_eventRegistry[eventName])
|
if(_eventRegistry[eventName])
|
||||||
{
|
{
|
||||||
SIOEvent e = _eventRegistry[eventName];
|
SIOEvent e = _eventRegistry[eventName];
|
||||||
|
@ -576,7 +578,7 @@ void SIOClient::fireEvent(const std::string& eventName, const std::string& data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log("SIOClient::fireEvent no event with name %s found", eventName.c_str());
|
log("SIOClient::fireEvent no native event with name %s found", eventName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//begin SocketIO methods
|
//begin SocketIO methods
|
||||||
|
@ -604,6 +606,13 @@ void SocketIO::destroyInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string& uri)
|
SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string& uri)
|
||||||
|
{
|
||||||
|
|
||||||
|
return SocketIO::connect(uri, delegate);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SIOClient* SocketIO::connect(const std::string& uri, SocketIO::SIODelegate& delegate)
|
||||||
{
|
{
|
||||||
std::string host = uri;
|
std::string host = uri;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
|
|
|
@ -92,6 +92,7 @@ public:
|
||||||
virtual void onMessage(SIOClient* client, const std::string& data) = 0;
|
virtual void onMessage(SIOClient* client, const std::string& data) = 0;
|
||||||
virtual void onClose(SIOClient* client) = 0;
|
virtual void onClose(SIOClient* client) = 0;
|
||||||
virtual void onError(SIOClient* client, const std::string& data) = 0;
|
virtual void onError(SIOClient* client, const std::string& data) = 0;
|
||||||
|
virtual void fireEventToScript(SIOClient* client, const std::string& eventName, const std::string& data) { CCLOG("SIODelegate event '%s' fired with data: %s", eventName.c_str(), data.c_str()); };
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,7 +101,9 @@ public:
|
||||||
* @param uri The URI of the socket.io server
|
* @param uri The URI of the socket.io server
|
||||||
* @return An initialized SIOClient if connected successfully, otherwise NULL
|
* @return An initialized SIOClient if connected successfully, otherwise NULL
|
||||||
*/
|
*/
|
||||||
static SIOClient* connect(SocketIO::SIODelegate& delegate, const std::string& uri);
|
static SIOClient* connect(const std::string& uri, SocketIO::SIODelegate& delegate);
|
||||||
|
|
||||||
|
CC_DEPRECATED_ATTRIBUTE static SIOClient* connect(SocketIO::SIODelegate& delegate, const std::string& uri);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue