123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- -------------------------------------------------
- -- 本文件由代码生成器自动生成,
- -- 千万不要修改本文件的任何代码,
- -- 修改的的任何代码都会被覆盖掉!
- ----------------------------------------------------
- local Socket = require "Xmds.Pomelo.LuaGameSocket"
- require "base64"
- require "chatHandler_pb"
- --------------------------------Pomelo-------------------------------
- Pomelo = Pomelo or {}
- --------------------------------ChatHandler-------------------------------
- Pomelo.ChatHandler = {}
- local function sendChatRequestEncoder(msg)
- local input = chatHandler_pb.SendChatRequest()
- protobuf.FromMessage(input,msg)
- return (input:SerializeToString())
- end
- local function sendChatRequestDecoder(stream)
- local res = chatHandler_pb.SendChatResponse()
- res:ParseFromString(stream)
- return res
- end
- function Pomelo.ChatHandler.sendChatRequest(c2s_scope,c2s_content,c2s_acceptRoleId,cb,option)
- local msg = {}
- msg.c2s_scope = c2s_scope
- msg.c2s_content = c2s_content
- msg.c2s_acceptRoleId = c2s_acceptRoleId
- Socket.OnRequestStart("chat.chatHandler.sendChatRequest", option)
- Socket.Request("chat.chatHandler.sendChatRequest", msg, function(res)
- if(res.s2c_code == 200) then
- Pomelo.ChatHandler.lastSendChatResponse = res
- Socket.OnRequestEnd("chat.chatHandler.sendChatRequest", true)
- cb(nil,res)
- else
- local ex = {}
- if(res.s2c_code) then
- ex.Code = res.s2c_code
- ex.Message = res.s2c_msg
- else
- ex.Code = 501
- ex.Message = "[LuaXmdsNetClient] chat.chatHandler.sendChatRequest decode error!!"
- end
- Socket.OnRequestEnd("chat.chatHandler.sendChatRequest", false,ex.Code,ex.Message)
- cb(ex,nil)
- end
- end, sendChatRequestEncoder, sendChatRequestDecoder)
- end
- local function getSaveChatMsgRequestEncoder(msg)
- local input = chatHandler_pb.GetSaveChatMsgRequest()
- protobuf.FromMessage(input,msg)
- return (input:SerializeToString())
- end
- local function getSaveChatMsgRequestDecoder(stream)
- local res = chatHandler_pb.GetSaveChatMsgResponse()
- res:ParseFromString(stream)
- return res
- end
- function Pomelo.ChatHandler.getSaveChatMsgRequest(c2s_scope,c2s_index,c2s_uid,cb,option)
- local msg = {}
- msg.c2s_scope = c2s_scope
- msg.c2s_index = c2s_index
- msg.c2s_uid = c2s_uid
- Socket.OnRequestStart("chat.chatHandler.getSaveChatMsgRequest", option)
- Socket.Request("chat.chatHandler.getSaveChatMsgRequest", msg, function(res)
- if(res.s2c_code == 200) then
- Pomelo.ChatHandler.lastGetSaveChatMsgResponse = res
- Socket.OnRequestEnd("chat.chatHandler.getSaveChatMsgRequest", true)
- cb(nil,res)
- else
- local ex = {}
- if(res.s2c_code) then
- ex.Code = res.s2c_code
- ex.Message = res.s2c_msg
- else
- ex.Code = 501
- ex.Message = "[LuaXmdsNetClient] chat.chatHandler.getSaveChatMsgRequest decode error!!"
- end
- Socket.OnRequestEnd("chat.chatHandler.getSaveChatMsgRequest", false,ex.Code,ex.Message)
- cb(ex,nil)
- end
- end, getSaveChatMsgRequestEncoder, getSaveChatMsgRequestDecoder)
- end
- local function crossChatSwitchButtonRequestEncoder(msg)
- local input = chatHandler_pb.CrossChatSwitchButtonRequest()
- protobuf.FromMessage(input,msg)
- return (input:SerializeToString())
- end
- local function crossChatSwitchButtonRequestDecoder(stream)
- local res = chatHandler_pb.CrossChatSwitchButtonResponse()
- res:ParseFromString(stream)
- return res
- end
- function Pomelo.ChatHandler.crossChatSwitchButtonRequest(isAllServerChat,optype,cb,option)
- local msg = {}
- msg.isAllServerChat = isAllServerChat
- msg.optype = optype
- Socket.OnRequestStart("chat.chatHandler.crossChatSwitchButtonRequest", option)
- Socket.Request("chat.chatHandler.crossChatSwitchButtonRequest", msg, function(res)
- if(res.s2c_code == 200) then
- Pomelo.ChatHandler.lastCrossChatSwitchButtonResponse = res
- Socket.OnRequestEnd("chat.chatHandler.crossChatSwitchButtonRequest", true)
- cb(nil,res)
- else
- local ex = {}
- if(res.s2c_code) then
- ex.Code = res.s2c_code
- ex.Message = res.s2c_msg
- else
- ex.Code = 501
- ex.Message = "[LuaXmdsNetClient] chat.chatHandler.crossChatSwitchButtonRequest decode error!!"
- end
- Socket.OnRequestEnd("chat.chatHandler.crossChatSwitchButtonRequest", false,ex.Code,ex.Message)
- cb(ex,nil)
- end
- end, crossChatSwitchButtonRequestEncoder, crossChatSwitchButtonRequestDecoder)
- end
- local function onChatPushDecoder(stream)
- local res = chatHandler_pb.OnChatPush()
- res:ParseFromString(stream)
- return res
- end
- function Pomelo.ChatHandler.onChatPush(cb)
- Socket.On("chat.chatPush.onChatPush", function(res)
- Pomelo.ChatHandler.lastOnChatPush = res
- cb(nil,res)
- end, onChatPushDecoder)
- end
- local function onChatErrorPushDecoder(stream)
- local res = chatHandler_pb.OnChatErrorPush()
- res:ParseFromString(stream)
- return res
- end
- function Pomelo.ChatHandler.onChatErrorPush(cb)
- Socket.On("chat.chatPush.onChatErrorPush", function(res)
- Pomelo.ChatHandler.lastOnChatErrorPush = res
- cb(nil,res)
- end, onChatErrorPushDecoder)
- end
- local function tipPushDecoder(stream)
- local res = chatHandler_pb.TipPush()
- res:ParseFromString(stream)
- return res
- end
- function Pomelo.ChatHandler.tipPush(cb)
- Socket.On("chat.chatPush.tipPush", function(res)
- Pomelo.ChatHandler.lastTipPush = res
- cb(nil,res)
- end, tipPushDecoder)
- end
- --------------------------------Pomelo-------------------------------
- return Pomelo
|