You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

4 years ago
4 years ago
4 years ago
4 years ago
  1. // Package ziface 主要提供zinx全部抽象层接口定义.
  2. // 包括:
  3. // IServer 服务mod接口
  4. // IRouter 路由mod接口
  5. // IConnection 连接mod层接口
  6. // IMessage 消息mod接口
  7. // IDataPack 消息拆解接口
  8. // IMsgHandler 消息处理及协程池接口
  9. //
  10. // 当前文件描述:
  11. // @Title iconnection.go
  12. // @Description 全部连接相关方法声明
  13. // @Author Aceld - Thu Mar 11 10:32:29 CST 2019
  14. package ziface
  15. import (
  16. "context"
  17. "net"
  18. )
  19. //定义连接接口
  20. type IConnection interface {
  21. Start() //启动连接,让当前连接开始工作
  22. Stop() //停止连接,结束当前连接状态M
  23. Context() context.Context //返回ctx,用于用户自定义的go程获取连接退出状态
  24. GetTCPConnection() *net.TCPConn //从当前连接获取原始的socket TCPConn
  25. GetConnID() uint32 //获取当前连接ID
  26. RemoteAddr() net.Addr //获取远程客户端地址信息
  27. SendMsg(msgID uint32, data []byte) error //直接将Message数据发送数据给远程的TCP客户端(无缓冲)
  28. SendBuffMsg(msgID uint32, data []byte) error //直接将Message数据发送给远程的TCP客户端(有缓冲)
  29. SetProperty(key string, value interface{}) //设置链接属性
  30. GetProperty(key string) (interface{}, error) //获取链接属性
  31. RemoveProperty(key string) //移除链接属性
  32. }