Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
若汝棋茗
RRQMSocket
提交
eeddea98
RRQMSocket
项目概览
若汝棋茗
/
RRQMSocket
10 个月 前同步成功
通知
20
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
RRQMSocket
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
eeddea98
编写于
2月 21, 2023
作者:
若
若汝棋茗
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新WaitingOptions,支持udp指定发送
上级
bd00562a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
32 deletion
+53
-32
src/TouchSocket/Sockets/WaitingClient/IWaitingClient.cs
src/TouchSocket/Sockets/WaitingClient/IWaitingClient.cs
+2
-4
src/TouchSocket/Sockets/WaitingClient/WaitingClient.cs
src/TouchSocket/Sockets/WaitingClient/WaitingClient.cs
+26
-7
src/TouchSocket/Sockets/WaitingClient/WaitingClientExtension.cs
...uchSocket/Sockets/WaitingClient/WaitingClientExtension.cs
+1
-1
src/TouchSocket/Sockets/WaitingClient/WaitingOptions.cs
src/TouchSocket/Sockets/WaitingClient/WaitingOptions.cs
+23
-19
src/TouchSocket/TouchSocket.csproj
src/TouchSocket/TouchSocket.csproj
+1
-1
未找到文件。
src/TouchSocket/Sockets/WaitingClient/IWaitingClient.cs
浏览文件 @
eeddea98
...
...
@@ -20,20 +20,18 @@ namespace TouchSocket.Sockets
/// <summary>
/// 等待型客户端。
/// </summary>
public
interface
IWaitingClient
<
TClient
>
:
IWaitSender
where
TClient
:
IClient
,
IDefaultSender
,
ISender
public
interface
IWaitingClient
<
TClient
>
:
IWaitSender
,
IDisposable
where
TClient
:
IClient
,
IDefaultSender
,
ISender
{
/// <summary>
/// 等待设置。
/// </summary>
public
WaitingOptions
WaitingOptions
{
get
;
set
;
}
public
WaitingOptions
WaitingOptions
{
get
;}
/// <summary>
/// 客户端终端
/// </summary>
TClient
Client
{
get
;
}
/// <summary>
/// 发送字节流
/// </summary>
...
...
src/TouchSocket/Sockets/WaitingClient/WaitingClient.cs
浏览文件 @
eeddea98
...
...
@@ -18,7 +18,7 @@ using TouchSocket.Resources;
namespace
TouchSocket.Sockets
{
internal
class
WaitingClient
<
TClient
>
:
IWaitingClient
<
TClient
>
where
TClient
:
IClient
,
IDefaultSender
,
ISender
internal
class
WaitingClient
<
TClient
>
:
DisposableObject
,
IWaitingClient
<
TClient
>
where
TClient
:
IClient
,
IDefaultSender
,
ISender
{
private
readonly
WaitData
<
ResponsedData
>
m_waitData
;
...
...
@@ -74,8 +74,7 @@ namespace TouchSocket.Sockets
{
breaked
=
false
;
m_waitData
.
Reset
();
if
(
this
.
WaitingOptions
.
BreakTrigger
&&
this
.
Client
is
ITcpClientBase
tcpClient
)
if
(
WaitingOptions
.
BreakTrigger
&&
this
.
Client
is
ITcpClientBase
tcpClient
)
{
tcpClient
.
Disconnected
+=
this
.
OnDisconnected
;
}
...
...
@@ -89,13 +88,27 @@ namespace TouchSocket.Sockets
Client
.
OnHandleRawBuffer
+=
OnHandleRawBuffer
;
}
if
(
WaitingOptions
.
AdapterFilter
==
AdapterFilter
.
AllAdapter
||
WaitingOptions
.
AdapterFilter
==
AdapterFilter
.
SendAdapter
)
if
(
WaitingOptions
.
RemoteIPHost
!=
null
&&
Client
is
IUdpSession
session
)
{
Client
.
Send
(
buffer
,
offset
,
length
);
if
(
WaitingOptions
.
AdapterFilter
==
AdapterFilter
.
AllAdapter
||
WaitingOptions
.
AdapterFilter
==
AdapterFilter
.
SendAdapter
)
{
session
.
Send
(
WaitingOptions
.
RemoteIPHost
.
EndPoint
,
buffer
,
offset
,
length
);
}
else
{
session
.
DefaultSend
(
WaitingOptions
.
RemoteIPHost
.
EndPoint
,
buffer
,
offset
,
length
);
}
}
else
{
Client
.
DefaultSend
(
buffer
,
offset
,
length
);
if
(
WaitingOptions
.
AdapterFilter
==
AdapterFilter
.
AllAdapter
||
WaitingOptions
.
AdapterFilter
==
AdapterFilter
.
SendAdapter
)
{
Client
.
Send
(
buffer
,
offset
,
length
);
}
else
{
Client
.
DefaultSend
(
buffer
,
offset
,
length
);
}
}
m_waitData
.
SetCancellationToken
(
token
);
...
...
@@ -328,6 +341,13 @@ namespace TouchSocket.Sockets
});
}
protected
override
void
Dispose
(
bool
disposing
)
{
this
.
Client
=
default
;
this
.
m_waitData
.
SafeDispose
();
base
.
Dispose
(
disposing
);
}
private
void
OnDisconnected
(
ITcpClientBase
client
,
DisconnectEventArgs
e
)
{
breaked
=
true
;
...
...
@@ -356,7 +376,6 @@ namespace TouchSocket.Sockets
{
responsedData
=
new
ResponsedData
(
null
,
requestInfo
);
}
return
!
m_waitData
.
Set
(
responsedData
);
}
}
...
...
src/TouchSocket/Sockets/WaitingClient/WaitingClientExtension.cs
浏览文件 @
eeddea98
...
...
@@ -27,7 +27,7 @@ namespace TouchSocket.Sockets
/// <param name="client"></param>
/// <param name="waitingOptions"></param>
/// <returns></returns>
public
static
IWaitingClient
<
TClient
>
GetWaitingClient
<
TClient
>(
this
TClient
client
,
WaitingOptions
waitingOptions
)
where
TClient
:
I
Client
,
IDefaultSender
,
ISender
public
static
IWaitingClient
<
TClient
>
GetWaitingClient
<
TClient
>(
this
TClient
client
,
WaitingOptions
waitingOptions
)
where
TClient
:
I
TcpClientBase
{
WaitingClient
<
TClient
>
waitingClient
=
new
WaitingClient
<
TClient
>(
client
,
waitingOptions
);
return
waitingClient
;
...
...
src/TouchSocket/Sockets/WaitingClient/WaitingOptions.cs
浏览文件 @
eeddea98
...
...
@@ -14,49 +14,53 @@
namespace
TouchSocket.Sockets
{
/// <summary>
///
等待设置
///
适配器筛选
/// </summary>
public
class
WaitingOptions
public
enum
AdapterFilter
{
/// <summary>
///
当Client为Tcp系时。是否在断开连接时以异常返回结果。
///
发送和接收都经过适配器
/// </summary>
public
bool
ThrowBreakException
{
get
;
set
;
}
=
true
;
AllAdapter
,
/// <summary>
///
当Client为Tcp系时。是否在断开连接时立即触发结果。默认会返回null。当<see cref="ThrowBreakException"/>为<see langword="true"/>时,会触发异常。
///
发送经过适配器,接收不经过
/// </summary>
public
bool
BreakTrigger
{
get
;
set
;
}
SendAdapter
,
/// <summary>
///
适配器筛选
///
发送不经过适配器,接收经过
/// </summary>
public
AdapterFilter
AdapterFilter
{
get
;
set
;
}
=
AdapterFilter
.
AllAdapter
;
WaitAdapter
,
/// <summary>
/// 全都不经过适配器。
/// </summary>
NoneAll
}
/// <summary>
///
适配器筛选
///
等待设置
/// </summary>
public
enum
AdapterFilter
public
class
WaitingOptions
{
/// <summary>
///
发送和接收都经过适配器
///
适配器筛选
/// </summary>
AllAdapter
,
public
AdapterFilter
AdapterFilter
{
get
;
set
;
}
=
AdapterFilter
.
AllAdapter
;
/// <summary>
///
发送经过适配器,接收不经过
///
当Client为Tcp系时。是否在断开连接时立即触发结果。默认会返回null。当<see cref="ThrowBreakException"/>为<see langword="true"/>时,会触发异常。
/// </summary>
SendAdapter
,
public
bool
BreakTrigger
{
get
;
set
;
}
/// <summary>
///
发送不经过适配器,接收经过
///
远程地址(仅在Udp模式下生效)
/// </summary>
WaitAdapter
,
public
IPHost
RemoteIPHost
{
get
;
set
;
}
/// <summary>
///
全都不经过适配器
。
///
当Client为Tcp系时。是否在断开连接时以异常返回结果
。
/// </summary>
NoneAll
public
bool
ThrowBreakException
{
get
;
set
;
}
=
true
;
}
}
\ No newline at end of file
src/TouchSocket/TouchSocket.csproj
浏览文件 @
eeddea98
...
...
@@ -4,7 +4,7 @@
<ApplicationIcon>logo.ico</ApplicationIcon>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>D:\MyStore\13_Doc\Keys\TouchSocket.snk</AssemblyOriginatorKeyFile>
<Version>1.2.1
2
</Version>
<Version>1.2.1
3
</Version>
<LangVersion>8.0</LangVersion>
<Company>若汝棋茗</Company>
<Copyright>Copyright © 2023 若汝棋茗</Copyright>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录