到这里BeetleX组件代码讲解完成了,由于组件只封装了TCP基础通讯的功能,因此在内容上并不会有太多;通以上内容相信对BeetleX的设计有一定的了解,在使用上也更加容易。

涉及要点

  • Socket对象应用
  • SocketAsyncEventArgs对象应用
  • 线程池的应用与设计
  • 缓冲区的应用与设计
  • 网络数据流处理
  • TCP应用协议分析处理

    回顾主要对象

  • ServerOptions

负责服务信息配置
(https://github.com/IKende/BeetleX/blob/master/src/BeetleX/ServerOptions.cs)

  • ListenHandler

负责服务地址监听和接收连接
(https://github.com/IKende/BeetleX/blob/master/src/BeetleX/ListenHandler.cs)

  • TcpServer

负责服务整合,数据接收,发送和所有连接会话管理
(https://github.com/IKende/BeetleX/blob/master/src/BeetleX/TcpServer.cs)

  • TcpSession

负责连接的会话管理
https://github.com/IKende/BeetleX/blob/master/src/BeetleX/TcpSession.cs

  • IServerHandler

负责描述会话行为,主要包括,连接创建,释放和数据接收处理等事件
(https://github.com/IKende/BeetleX/blob/master/src/BeetleX/IServerHandler.cs)

  • IPacket

负责应用协议分析
https://github.com/IKende/BeetleX/blob/master/src/BeetleX/IMessageFormatr.cs

  • SocketFactory

负责服务和客户端创建
(https://github.com/IKende/BeetleX/blob/master/src/BeetleX/ServerFactory.cs)

  • Buffer

数据缓冲区,主要用于Socket的接收和发送数据
https://github.com/IKende/BeetleX/blob/master/src/BeetleX/Buffers/IBuffer.cs

  • BufferPool

数据级冲池,针对缓冲区进行分配和释放管理
(https://github.com/IKende/BeetleX/blob/master/src/BeetleX/Buffers/Pool.cs)

  • PipeStream

主要负责网络数据流读写,并提供ssl支持。
(https://github.com/IKende/BeetleX/blob/master/src/BeetleX/Buffers/PipeStream.cs)

  • SingleThreadDispatcher

线程队列,主要用于任务处理和执行
(https://github.com/IKende/BeetleX/blob/master/src/BeetleX/Dispatchs/Dispatcher.cs)

  • DispatchCenter

线程队列调度中心,负责多个线程队列的分配管理
(https://github.com/IKende/BeetleX/blob/master/src/BeetleX/Dispatchs/Dispatcher.cs)

反馈

如果你对文章的有意见或发现错误可以发邮件到admin@beetlex.io或henryfan@msn.com

计划

由于beetlex.io涉及的开源组件还是比较多,后面会把HTTP服务,网关等待相关组件也会进行一个详细讲述;不过这些组件的实现和讲解决就远比BeetleX基础组件来复杂,毕竟这些都是一个标准应用协议的完整实现,涉及的内容比较详细丰富。