XFEExtension.NetCore.ServerInteractive
[DLL] Server interaction extension, including user identity verification and querying in conjunction with AutoConfig
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore.ServerInteractive/Implements/CoreService/XFEServerCoreServiceBase.cs
+10
-1
Modified
XFEExtension.NetCore.ServerInteractive/Interfaces/CoreService/IXFEServerCoreServiceBase.cs
+42
-0
Modified
XFEExtension.NetCore.ServerInteractive/Models/ServerModels/ServerCoreReturnArgs.cs
+47
-0
Modified
XFEExtension.NetCore.ServerInteractive/XFEExtension.NetCore.ServerInteractive.csproj
+3
-7
XFEstudio/XFEExtension.NetCore.ServerInteractive
添加Send方法以及二进制数据发送方法
378da87
代码差异
4 个文件
+102
-8
@@ -21,7 +21,16 @@ public abstract class XFEServerCoreServiceBase : IXFEServerCoreServiceBase
21
21
public ServerCoreReturnArgs ReturnArgs { get; set; }
22
22
23
23
/// <inheritdoc/>
24
public async Task Close(string message) => await ReturnArgs!.Close(message);
24
public async Task Send(string message) => await ReturnArgs.Send(message);
25
26
/// <inheritdoc/>
27
public async Task Send(byte[] buffer) => await ReturnArgs.Send(buffer);
28
29
/// <inheritdoc/>
30
public async Task Send(Stream stream) => await ReturnArgs.Send(stream);
31
32
/// <inheritdoc/>
33
public async Task Close(string message) => await ReturnArgs.Close(message);
25
34
26
35
/// <inheritdoc/>
27
36
public void OK() => ReturnArgs?.OK();
@@ -30,6 +30,28 @@ public interface IXFEServerCoreServiceBase
30
30
/// </summary>
31
31
ServerCoreReturnArgs ReturnArgs { get; set; }
32
32
33
/// <summary>
34
/// Sends a reply message asynchronously using the current context.
35
/// </summary>
36
/// <param name="message">The message text to send as a reply. Cannot be null or empty.</param>
37
/// <returns>A task that represents the asynchronous send operation.</returns>
38
Task Send(string message);
39
40
/// <summary>
41
/// Sends a binary message using the specified buffer asynchronously.
42
/// </summary>
43
/// <param name="buffer">The byte array containing the data to be sent as the binary message. Cannot be null.</param>
44
/// <returns>A task that represents the asynchronous send operation.</returns>
45
Task Send(byte[] buffer);
46
47
/// <summary>
48
/// Sends the contents of the specified stream as a binary message asynchronously.
49
/// </summary>
50
/// <param name="stream">The stream containing the data to send. The stream must be readable and positioned at the beginning of the data
51
/// to be sent.</param>
52
/// <returns>A task that represents the asynchronous send operation.</returns>
53
Task Send(Stream stream);
54
33
55
/// <summary>
34
56
/// 关闭并返回 OK
35
57
/// </summary>
@@ -41,6 +63,26 @@ public interface IXFEServerCoreServiceBase
41
63
/// <param name="message">要返回的信息</param>
42
64
Task Close(string message);
43
65
66
/// <summary>
67
/// 结束与客户端的通讯
68
/// </summary>
69
/// <param name="buffer"></param>
70
public async Task Close(byte[] buffer)
71
{
72
await Send(buffer);
73
OK();
74
}
75
76
/// <summary>
77
/// 结束与客户端的通讯
78
/// </summary>
79
/// <param name="stream"></param>
80
public async Task Close(Stream stream)
81
{
82
await Send(stream);
83
OK();
84
}
85
44
86
/// <summary>
45
87
/// 返回错误信息并关闭
46
88
/// </summary>
@@ -25,6 +25,33 @@ public class ServerCoreReturnArgs : Exception
25
25
/// </summary>
26
26
public required CyberCommRequestEventArgs Args { get; set; }
27
27
28
/// <summary>
29
/// Sends a reply message asynchronously using the current context.
30
/// </summary>
31
/// <param name="message">The message text to send as a reply. Cannot be null or empty.</param>
32
/// <returns>A task that represents the asynchronous send operation.</returns>
33
public async Task Send(string message) => await Args.ReplyMessage(message);
34
35
/// <summary>
36
/// Sends a binary message using the specified buffer asynchronously.
37
/// </summary>
38
/// <param name="buffer">The byte array containing the data to be sent as the binary message. Cannot be null.</param>
39
/// <returns>A task that represents the asynchronous send operation.</returns>
40
public async Task Send(byte[] buffer) => await Args.ReplyBinaryMessage(buffer);
41
42
/// <summary>
43
/// Sends the contents of the specified stream as a binary message asynchronously.
44
/// </summary>
45
/// <param name="stream">The stream containing the data to send. The stream must be readable and positioned at the beginning of the data
46
/// to be sent.</param>
47
/// <returns>A task that represents the asynchronous send operation.</returns>
48
public async Task Send(Stream stream)
49
{
50
using var memoryStream = new MemoryStream();
51
await stream.CopyToAsync(memoryStream);
52
await Args.ReplyBinaryMessage(memoryStream.ToArray());
53
}
54
28
55
/// <summary>
29
56
/// 正常结束与客户端的通讯
30
57
/// </summary>
@@ -36,6 +63,26 @@ public class ServerCoreReturnArgs : Exception
36
63
/// <param name="message"></param>
37
64
public async Task Close(string message) => await Args.ReplyAndClose(message);
38
65
66
/// <summary>
67
/// 结束与客户端的通讯
68
/// </summary>
69
/// <param name="buffer"></param>
70
public async Task Close(byte[] buffer)
71
{
72
await Send(buffer);
73
OK();
74
}
75
76
/// <summary>
77
/// 结束与客户端的通讯
78
/// </summary>
79
/// <param name="stream"></param>
80
public async Task Close(Stream stream)
81
{
82
await Send(stream);
83
OK();
84
}
85
39
86
/// <summary>
40
87
/// 以异常结束与客户端的通讯
41
88
/// </summary>
@@ -5,7 +5,7 @@
5
5
<ImplicitUsings>enable</ImplicitUsings>
6
6
<Nullable>enable</Nullable>
7
7
<GenerateDocumentationFile>True</GenerateDocumentationFile>
8
<Version>1.1.3</Version>
8
<Version>1.1.4</Version>
9
9
<Title>XFEExtension.NetCore.ServerInteractive</Title>
10
10
<RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.ServerInteractive</RepositoryUrl>
11
11
<AnalysisLevel>latest</AnalysisLevel>
@@ -21,16 +21,12 @@
21
21
<PackageReleaseNotes>
22
22
## 调整
23
23
24
优化日志输出及版本号升级至1.1.3
25
26
- 异常警告信息输出由 Console.WriteLine 改为 Console.Write,避免自动换行,堆栈信息仍保持换行输出。
27
- 请求处理完成日志由“成功!”改为“[耗时 xxx]”,突出耗时信息。
28
- 项目版本号由 1.1.2 升级至 1.1.3。
24
无
29
25
30
26
31
27
## 新增
32
28
33
无
29
添加Send方法以及二进制数据发送方法
34
30
35
31
## 严重
36
32