static int set_OnEvent(IntPtr L) { try { SocketClient obj = (SocketClient)ToLua.CheckObject(L, 1, typeof(SocketClient)); EventObject arg0 = null; if (LuaDLL.lua_isuserdata(L, 2) != 0) { arg0 = (EventObject)ToLua.ToObject(L, 2); } else { return(LuaDLL.luaL_throw(L, "The event 'SocketClient.OnEvent' can only appear on the left hand side of += or -= when used outside of the type 'SocketClient'")); } if (arg0.op == EventOp.Add) { SocketClient.MessageHandler ev = (SocketClient.MessageHandler)arg0.func; obj.OnEvent += ev; } else if (arg0.op == EventOp.Sub) { SocketClient.MessageHandler ev = (SocketClient.MessageHandler)arg0.func; obj.OnEvent -= ev; } return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
///------------------------------------------------------------------------------------ public static void AddEvent(SocketClient.MessageHandler func, int eventID, ref LuaByteBuffer data) { lock (m_lockObject) { NetEvent e = new NetEvent(); e.func = func; e.eventID = eventID; e.data = data; mEvents.Enqueue(e); } }