lesismal / nbio

Pure Go 1000k+ connections solution, support tls/http1.x/websocket and basically compatible with net/http, with high-performance and low memory cost, non-blocking, event-driven, easy-to-use.
MIT License
2.11k stars 151 forks source link

如何增加序列化和反序列化的函数? #405

Closed awzhgw closed 2 months ago

awzhgw commented 3 months ago

我的传输body是这样的:

40字节header, 其中header指明了有多少长度的body。。然后再读取body。。

我看示例中,没有这类函数的调用方法?支持吗?

lesismal commented 3 months ago

可以用nbio.Conn.SetSession设置你自己的连接对应的结构体,然后OnData接收到数据时自己的结构体实现包括半包缓存、新数据拼接、header和body解析的逻辑

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.