/// <summary> /// Create a chunk. /// </summary> public static Chunk CreateChunk(IJdwpServerInfo serverInfo, int type, int dataLength, Action<Chunk> initialize = null) { var data = new byte[HeaderLength + ChunkHeaderLength + dataLength]; var packet = new Chunk(serverInfo, data, 0) { Type = type, Length = dataLength }; if (initialize != null) { initialize(packet); } return packet; }
/// <summary> /// Try to find a packet in the given buffer. /// </summary> /// <returns>Null if not found</returns> private static JdwpPacket FindPacket(IJdwpServerInfo serverInfo, byte[] buffer, int length) { if (length < JdwpPacket.HeaderLength) { return(null); } var pkt = new JdwpPacket(serverInfo, buffer, 0); if (pkt.Length > length) { return(null); } return(new JdwpPacket(serverInfo, buffer, 0, true)); }
/// <summary> /// Create a chunk. /// </summary> public static Chunk CreateChunk(IJdwpServerInfo serverInfo, int type, int dataLength, Action <Chunk> initialize = null) { var data = new byte[HeaderLength + ChunkHeaderLength + dataLength]; var packet = new Chunk(serverInfo, data, 0) { Type = type, Length = dataLength }; if (initialize != null) { initialize(packet); } return(packet); }
/// <summary> /// Create a command packet. /// </summary> public static JdwpPacket CreateCommand(IJdwpServerInfo serverInfo, int commandSet, int command, int dataLength, Action <JdwpPacket> initialize = null) { var data = new byte[HeaderLength + dataLength]; var packet = new JdwpPacket(serverInfo, data, 0) { CommandSet = commandSet, Command = command, Length = data.Length }; if (initialize != null) { initialize(packet); } return(packet); }
/// <summary> /// Default ctor /// </summary> public JdwpPacket(IJdwpServerInfo serverInfo, byte[] data, int dataOffset, bool cloneBuffer) { this.serverInfo = serverInfo; this.data = data; this.dataOffset = dataOffset; if (cloneBuffer) { var len = Length; var clone = new byte[len]; Array.Copy(data, dataOffset, clone, 0, len); this.data = clone; this.dataOffset = 0; } }
/// <summary> /// Default ctor /// </summary> public Chunk(IJdwpServerInfo serverInfo, byte[] data, int dataOffset) : base(serverInfo, data, dataOffset) { CommandSet = DdmsCommandSet; Command = DdmsCommand; }
/// <summary> /// Default ctor /// </summary> public JdwpPacket(IJdwpServerInfo serverInfo, byte[] data, int dataOffset) : this(serverInfo, data, dataOffset, false) { }
/// <summary> /// Create a command packet. /// </summary> public static JdwpPacket CreateCommand(IJdwpServerInfo serverInfo, int commandSet, int command, int dataLength, Action<JdwpPacket> initialize = null) { var data = new byte[HeaderLength + dataLength]; var packet = new JdwpPacket(serverInfo, data, 0) { CommandSet = commandSet, Command = command, Length = data.Length }; if (initialize != null) { initialize(packet); } return packet; }