【mini-asio】 轻量级夸平台底层客户端网络解决方案

1.现在的消息收发很奇怪,我们有一个帧同步的游戏,一段时间内消息不延迟,然后会暂停一下(2,3秒的样子),再收到一些消息,再暂停……循环这个流程;
2.频繁向服务端发送数据容易导致闪退。我这边测试,服务端向客户端频繁发消息或客户端不频繁的向服务端发消息不会导致闪退
3.使用的kcp的流模式;
4.上个版本不会闪退

好,我看看

再更新一下,应该不会闪退了: https://github.com/halx99/yasio/commit/c0e0d7bb6750863bb24093618b618b1ce8f15ca2

给你发了私消息,你看一下

最新修改,更新下,应该不会再出你说的奇怪现象了: https://github.com/halx99/yasio/commit/b75993ee5cf76031eaa481d1684821ef7b5f40a0

1赞

最新版本确实不会闪退了,消息也不会是一段一段的收了,辛苦大佬:pray:

yasio-v3.21.1~v3.21.3f1更新内容:

  1. 修复连接断开时错误码显示不正确问题
  2. 增加YASIO_NI API: yasio_set_console_print_fn
  3. 修复TCP keepalive选项不正确问题
  4. 增加yasio_memcpy for YASIO_NI, 方便C# Buffer NoGC优化
  5. 优化cocos lua,jsb,jsb2.0脚本绑定timer实现,添加killAll接口
1赞

yasio-3.22.0更新内容:

  1. 增加试验性kcp支持,使用编译宏YASIO_HAVE_KCP启用,channel掩码: YCM_KCP_CLIENT
  2. 修改obstream pop默认行为以适配类似tls handshake协议编码, 详见: https://github.com/halx99/yasio/wiki/obstream#Encapsulate-Packet
  3. 移除基本没用的发送超时设置选项
2赞

yasio-3.23.0

Make length field based frame decode associate with channel.
Make decode length function associate with channel.
Make transport send,flush as private for internal use.
Change channel default length decode behavior to directly.
Rename YOPT_RESOLV_FUNCTION to YOPT_RESOLV_FN.
Rename YOPT_CONSOLE_PRINT_FUNCTION to YOPT_CONSOLE_PRINT_FN.
Rename YOPT_DECODE_FRAME_LENGTH_FUNCTION to YOPT_CHANNEL_LFBFD_FN.
Rename YOPT_LFBFD_PARAMS to YOPT_CHANNEL_LFBFD_PARAMS.
Rename YOPT_IO_EVENT_CALLBACK to YOPT_IO_EVENT_CB.

yasio-3.23.1

  1. Fix UDP EPERM issue.
  2. Add option: YOPT_PRINT_FN.
  3. Remove option: YOPT_LOG_FILE and YOPT_CONSOLE_PRINT_FN.

紧跟大佬的脚步:3:

yasio-3.23.6

  1. Fix jsb & jsb20 compile issue.
  2. Rename native interface yasio_close2 to yasio_close_handle
  3. Support detect whether ipv6 supported at android platform.
  4. Use dual event queue to avoid block recv operation when consumer thread do Long-Running Operations at event callback.
  5. Remove specific vs project files, use cmake instead.
1赞

yasio-3.26.0发布

  1. 重命名宏定义YASIO_HAVE_KCP为YASIO_ENABLE_KCP并移至config.hpp文件
  2. 重命名宏定义_USING_OBJECT_POOL为YASIO_DISABLE_OBJECT_POOL并移至config.hpp文件.
  3. 增加宏定义YASIO_DISABLE_SPSC_QUEUE是否使用支持无锁并发的单生产着单消费者队列
  4. 修改时间回调io_event_cb_t参数为右值引用

https://github.com/halx99/yasio/releases

1赞

建议不要用线程。。。。。。。。。
tcp连接,异步是最好的方案

了解一下多核艺术

设计原本就是nonblocking的,进一步隐藏传输细节,和ws异曲同工, 区别就是更纯粹一些

线程建议看看这篇文章: https://zhuanlan.zhihu.com/p/81810132

yasio-3.30.0 发布

Tidy option macros.
Add YCF_ enums to control channel to support more features.
Add multicast support.
Add a workaround implementation to support win32 udp-server.
Add io_service::cindex_to_handle.
Add ftp sever example.
Remove loop behavior of deadline_timer, user can schedule again when it’s expired.
Add obstream::write_byte.
Add to_strf_v4 for ip::endpoint.
Optimizing for file transfer, avoid high cpu occupation when system kernel send buffer is full.
More safe to check object valid which allocated from pool.
Add send complete callback.
Mark io_service::dispatch_events deprecated, use dispatch to instead.
Add YCF_REUSEPORT to control whether to enable socket can bind same port, default and previous vesion is enabled.
Implement case insensitive starts_with, ends_with at string_view.hpp.
Ignore SIGPIPE for tcp at non-win32 system.
Remove reconnect timeout.

异步其实是主线程托管了一个线程而已,
不要迷恋线程,尤其是客户端。

哎,确实太重了,要不起