|
@@ -35,16 +35,15 @@ func subStr(str string, length int) string {
|
|
|
|
|
|
|
|
type Hub struct {
|
|
type Hub struct {
|
|
|
sync.Mutex
|
|
sync.Mutex
|
|
|
- ctx context.Context // 为了方便退出而建立
|
|
|
|
|
- cancel context.CancelFunc
|
|
|
|
|
- cf *config.Config
|
|
|
|
|
- globalID uint16
|
|
|
|
|
- channel string // 本地频道信息
|
|
|
|
|
- middle []MiddleFunc // 中间件
|
|
|
|
|
- // connects sync.Map // map[*Line]bool(true) //记录当前的连接,方便查找
|
|
|
|
|
- lines *Mapx // 记录当前的连接,统一管理
|
|
|
|
|
- subscribes sync.Map // [cmd]->[]*SubscribeData //注册绑定频道的函数,用于响应请求
|
|
|
|
|
- msgCache sync.Map // map[uint16]*GetMsg //请求的回应记录,key为id
|
|
|
|
|
|
|
+ ctx context.Context // 为了方便退出而建立
|
|
|
|
|
+ cancel context.CancelFunc
|
|
|
|
|
+ cf *config.Config
|
|
|
|
|
+ globalID uint16
|
|
|
|
|
+ channel string // 本地频道信息
|
|
|
|
|
+ middle []MiddleFunc // 中间件
|
|
|
|
|
+ lines *Mapx // 记录当前的连接,统一管理
|
|
|
|
|
+ subscribes sync.Map // [cmd]->[]*SubscribeData //注册绑定频道的函数,用于响应请求
|
|
|
|
|
+ msgCache sync.Map // map[uint16]*GetMsg //请求的回应记录,key为id
|
|
|
|
|
|
|
|
// 客户端需要用的函数(服务端可为空)
|
|
// 客户端需要用的函数(服务端可为空)
|
|
|
connectHostFunc ConnectHostFunc // 获取对应频道的一个连接地址
|
|
connectHostFunc ConnectHostFunc // 获取对应频道的一个连接地址
|