Skip to content

Commit 0553507

Browse files
committed
QpChannel add method 'SendCommandRequest'
1 parent 62ca809 commit 0553507

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Quick.Protocol/CommandContext.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Quick.Protocol
88
{
99
public class CommandContext
1010
{
11+
public static string GenerateNewId() => Guid.NewGuid().ToString("N").ToLower();
1112
public string Id { get; private set; }
1213
private CommandException commandException;
1314
private bool isTimeout = false;
@@ -16,7 +17,7 @@ public class CommandContext
1617

1718
public CommandContext(string typeName)
1819
{
19-
Id = Guid.NewGuid().ToString("N").ToLower();
20+
Id = GenerateNewId();
2021
ResponseTask = new Task<CommandResponseTypeNameAndContent>(() =>
2122
{
2223
if (isTimeout)

Quick.Protocol/QpChannel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,19 @@ public Task SendNoticePackage(object package)
492492
return SendNoticePackage(package.GetType().FullName, JsonConvert.SerializeObject(package));
493493
}
494494

495+
/// <summary>
496+
/// 发送命令请求包
497+
/// </summary>
498+
/// <param name="request"></param>
499+
/// <returns></returns>
500+
public async Task SendCommandRequest(object request)
501+
{
502+
var requestType = request.GetType();
503+
var typeName = requestType.FullName;
504+
var requestContent = JsonConvert.SerializeObject(request);
505+
await SendCommandRequestPackage(CommandContext.GenerateNewId(), typeName, requestContent);
506+
}
507+
495508
/// <summary>
496509
/// 发送命令请求包
497510
/// </summary>

0 commit comments

Comments
 (0)