/// <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> /// Handle non-reply chunks /// </summary> private void ChunkHandler(Chunk chunk) { DLog.Debug(DContext.DebuggerLibDebugger, "Handle Chunk {0}", chunk); var type = chunk.Type; if (type == DdmsCommandSet.HeloType) { var data = chunk.Data; var clientProtocolVersion = data.GetInt(); var pid = data.GetInt(); var vmIdentLen = data.GetInt(); var appNameLen = data.GetInt(); var vmIdent = data.GetString(vmIdentLen); var appName = data.GetString(appNameLen); SetAppName(appName); } else if (type == DdmsCommandSet.ApnmType) { var data = chunk.Data; var appNameLen = data.GetInt(); var appName = data.GetString(appNameLen); SetAppName(appName); } else if (type == DdmsCommandSet.WaitType) { var data = chunk.Data; var reason = data.GetByte(); OnEventAsync(new WaitForDebugger(reason)); } else if (type == DdmsCommandSet.ThstType) { ThreadStatus.HandleTHST(chunk, OnEventAsync); } }