Merge commit 'refs/pull/5923/head' of git://github.com/cocos2d/cocos2d-x into merge5923

This commit is contained in:
James Chen 2014-03-24 17:55:43 +08:00
commit b6a175457c
2 changed files with 15 additions and 3 deletions

View File

@ -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());
_delegate->fireEventToScript(this, eventName, data);
if(_eventRegistry[eventName])
{
SIOEvent e = _eventRegistry[eventName];
@ -576,7 +578,7 @@ void SIOClient::fireEvent(const std::string& eventName, const std::string& data)
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
@ -603,7 +605,14 @@ void SocketIO::destroyInstance()
CC_SAFE_DELETE(_inst);
}
SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string& uri)
CC_DEPRECATED_ATTRIBUTE 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;
int port = 0;

View File

@ -92,6 +92,7 @@ public:
virtual void onMessage(SIOClient* client, const std::string& data) = 0;
virtual void onClose(SIOClient* client) = 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
* @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: