Esempio n. 1
0
        static public int sendMessage(IntPtr state)
        {
            luaProtobuf self = (luaProtobuf)LuaObject.checkSelf(state);

            //消息ID
            int idMsg = LuaDLL.luaL_checkinteger(state, 2);

            //消息内容
            LuaTypes type = LuaDLL.lua_type(state, 3);

            if (type != LuaTypes.LUA_TTABLE)
            {
                LogSys.LogError("LUA message error! idMsg = " + idMsg.ToString());
                return(0);
            }
            LuaTable msgTbl = (LuaTable)LuaObject.checkVar(state, 3);

            //生成消息
            luaMessage msg = luaProtoHelper.readLuaMessage(idMsg, msgTbl);

            //写入流并发出
            using (var stream = new System.IO.MemoryStream())
            {
                using (var protoWriter = new luaProtoWriter(stream))
                {
                    protoWriter.writeLuaMessage(msg);
                    protoWriter.close();
                }
                network.protobuf.ClientNetwork.Instance.SendLuaMsg(idMsg, stream);
            }

            LuaObject.pushValue(state, true);
            return(1);
        }
Esempio n. 2
0
 static public int removeMessageHandler(IntPtr l)
 {
     try {
         sluaAux.luaProtobuf self = (sluaAux.luaProtobuf)checkSelf(l);
         System.Int32        a1;
         checkType(l, 2, out a1);
         self.removeMessageHandler(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 3
0
        public static luaProtobuf getInstance()
        {
            if (_instance == null)
            {
                lock (lockHelper)
                {
                    if (_instance == null)
                    {
                        _instance = new luaProtobuf();
                    }
                }
            }

            return(_instance);
        }