private void onReceiveSocket() { while (true) { if (!_clientSocket.Connected) { break; } try { int receiveLength = _clientSocket.Receive(_result); if (receiveLength > 0) { ByteBuffer buffer = new ByteBuffer(_result); int command = buffer.ReadInt(); byte[] data = buffer.ReadBytes(); DebugManager.Log("服务器指令:" + command); OnReceiveMessage(command, data); } } catch (Exception e) { DebugManager.Log(e.Message); } } }
static int ReadInt(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); CFramework.ByteBuffer obj = (CFramework.ByteBuffer)ToLua.CheckObject <CFramework.ByteBuffer>(L, 1); int o = obj.ReadInt(); LuaDLL.lua_pushinteger(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }