您的位置:首页 > 理论基础 > 计算机网络

lua网络数据请求过程

2016-05-18 12:36 966 查看
1.ResponseController 注册消息
-- 定向抽卡
commandFuncMap[ CommandTypes.ClarityDrawState ] = function( commandId, buffer )
local data = ClarityDrawStateResponse:create()
data:readFromBuffer( buffer )

return data
end

-- 请求抽卡
commandFuncMap[ CommandTypes.ClarityDrawStart ] = function( commandId, buffer )
local data = ClarityDrawStartResponse:create()
data:readFromBuffer( buffer )

if  data.errorNo == ErrorNo.NO_ERROR then
PropService:updatePropList( data.propChange )
PlayerService:updateMoney( data.moneyChange )
end

return data
end

2.向服务器发送请求
function MainScene:levelCallBack( sender, type )
local msg = LevelGiftRewardRequest:create()
NetManager:sendHttpRequest( msg, true )
end

3.得到服务器返回的数据data
commandId == CommandTypes.LevelGiftReward then
if data.errorNo == ErrorNo.NO_ERROR then
local dialog = ActivityFastView:create( self, data.levelGiftItem )
UIManager:openDialog( dialog )

UI.setVisible( self.levelTips, false )
end

4.从服务器返回得到的data数据中的东西显示在界面上。
function ActivityFastView:create( parent, activityList )
local view = ActivityFastView:new()
view:__init( parent, activityList )
return view
end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: