Files
TouchSocket/handbook/docs/udpdatahandlingadapter.mdx
若汝棋茗 72e0a65742 feat(docs): 添加多个组件的导入和解析功能
在多个 `.mdx` 文件中添加对 `TouchSocketCoreDefinition`、`TouchSocketHttpDefinition`、`TouchSocketDmtpDefinition`、`TouchSocketModbusDefinition`、`TouchSocketProModbusDefinition`、`TouchSocketNamedPipeDefinition`、`TouchSocketWebApiDefinition`、`TouchSocketJsonRpcDefinition` 和 `TouchSocketXmlRpcDefinition` 的导入。增加解析和处理定义部分的 JavaScript 脚本,确保导入的有效性和一致性。新增功能包括精确匹配定义部分的正则表达式、解析定义内容的函数、生成定义组件的函数、递归查找 `.mdx` 文件的功能,以及验证导入的有效性
2025-07-09 22:22:17 +08:00

50 lines
1.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: udpdatahandlingadapter
sidebar_position: 1
title: 原始自定义适配器
sidebar_label: a.原始自定义适配器
---
import { TouchSocketDefinition } from "@site/src/components/Definition.js";
### 定义
<TouchSocketDefinition />
## 说明
Udp的适配器主要承担组包和解析数据。其基本逻辑和Tcp相似。但是需要注意的是Udp适配器是**多线程**操作。在解析数据时,应当充分考虑并发问题。
```csharp showLineNumbers
class MyUdpAdatper : UdpDataHandlingAdapter
{
public override bool CanSplicingSend => false;
protected override void PreviewReceived(EndPoint remoteEndPoint, ByteBlock byteBlock)
{
}
protected override void PreviewSend(EndPoint endPoint, byte[] buffer, int offset, int length, bool isAsync)
{
}
protected override void PreviewSend(EndPoint endPoint, IList<TransferByte> transferBytes, bool isAsync)
{
}
protected override void Reset()
{
}
}
```
## 单元测试
使用**UdpDataAdapterTester**即可测试。