public byte[] Set(ByteBuffer _bb) { _bb = new ByteBuffer(_bb.ToBytes()); byte[] _msgid = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(_bb.ReadInt())); byte[] _sign = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(_bb.ReadInt())); byte[] _body = _bb.ReadBytes(); byte[] _length = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(_body.Length)); byte[] _array = new byte[_body.Length + totalHead]; Array.Copy(_length, 0, _array, 0, _length.Length); Array.Copy(_msgid, 0, _array, 4, _msgid.Length); Array.Copy(_msgid, 0, _array, 8, _sign.Length); Array.Copy(_body, 0, _array, 12, _body.Length); return(_array); }
static int ReadInt(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); GameFramework.ByteBuffer obj = (GameFramework.ByteBuffer)ToLua.CheckObject <GameFramework.ByteBuffer>(L, 1); int o = obj.ReadInt(); LuaDLL.lua_pushinteger(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }