Merge pull request #5015 from samuele3hu/developNewUI

closed #3643:Lua websocket can't receive more than 64 bytes of data
This commit is contained in:
James Chen 2014-01-09 02:12:49 -08:00
commit 2ce23dca2a
1 changed files with 12 additions and 8 deletions

View File

@ -102,18 +102,22 @@ void LuaWebSocket::onMessage(WebSocket* ws, const WebSocket::Data& data)
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws); LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) { if (NULL != luaWs) {
if (data.isBinary) { if (data.isBinary) {
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE);
if (0 != nHandler) { if (0 != handler) {
SendBinaryMessageToLua(nHandler, (const unsigned char*)data.bytes, data.len); SendBinaryMessageToLua(handler, (const unsigned char*)data.bytes, data.len);
} }
} }
else{ else{
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE);
if (0 != nHandler) { if (0 != handler)
CommonScriptData commonData(nHandler,data.bytes); {
ScriptEvent event(kCommonEvent,(void*)&commonData); LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); if (nullptr != stack)
{
stack->pushString(data.bytes,data.len);
stack->executeFunctionByHandler(handler, 1);
}
} }
} }
} }