2013-06-06 22:29:02 +08:00
|
|
|
#ifndef __LUA_WEB_SOCKET_H__
|
|
|
|
#define __LUA_WEB_SOCKET_H__
|
|
|
|
|
2013-07-17 14:44:28 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
|
|
|
|
2013-06-06 22:29:02 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
#include "tolua++.h"
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2013-07-17 10:15:25 +08:00
|
|
|
|
2013-07-17 14:44:28 +08:00
|
|
|
#include "network/WebSocket.h"
|
2013-07-17 10:15:25 +08:00
|
|
|
class LuaWebSocket: public cocos2d::extension::WebSocket,public cocos2d::extension::WebSocket::Delegate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~LuaWebSocket();
|
|
|
|
virtual void onOpen(WebSocket* ws);
|
|
|
|
virtual void onMessage(WebSocket* ws, const WebSocket::Data& data);
|
|
|
|
virtual void onClose(WebSocket* ws);
|
|
|
|
virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error);
|
|
|
|
|
|
|
|
enum WebSocketScriptHandlerType
|
|
|
|
{
|
|
|
|
kWebSocketScriptHandlerOpen,
|
|
|
|
kWebSocketScriptHandlerMessage,
|
|
|
|
kWebSocketScriptHandlerClose,
|
|
|
|
kWebSocketScriptHandlerError,
|
|
|
|
};
|
|
|
|
};
|
2013-06-06 22:29:02 +08:00
|
|
|
|
|
|
|
TOLUA_API int tolua_web_socket_open(lua_State* tolua_S);
|
|
|
|
|
2013-07-17 14:44:28 +08:00
|
|
|
#endif //(CC_TARGET_PLATFORM == CC_PLATFORM_IOS ...
|
|
|
|
|
2013-06-06 22:29:02 +08:00
|
|
|
#endif //__LUA_WEB_SOCKET_H__
|