|
|
@@ -6,7 +6,7 @@ import (
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
- // Hub 状态
|
|
|
+ //
|
|
|
DefHubConfig = HubConfig{
|
|
|
SizeOfSendChan: 1024,
|
|
|
SizeOfRecvChan: 1024,
|
|
|
@@ -21,28 +21,28 @@ var (
|
|
|
type HubConfig struct {
|
|
|
SizeOfSendChan uint32
|
|
|
SizeOfRecvChan uint32
|
|
|
- ReadBufSize int
|
|
|
- WriteBufSize int
|
|
|
- Timeout time.Duration // 发送等超时
|
|
|
- Tick time.Duration // 定时回调
|
|
|
- ReadTimeout time.Duration // 讀超時,如果為0,則無限等待。超時到達,意味著客戶端心跳丟失
|
|
|
+ ReadBufSize int // used in websocket
|
|
|
+ WriteBufSize int // used in websocket
|
|
|
+ Timeout time.Duration // for write && listener
|
|
|
+ Tick time.Duration // heartbeat callback interval
|
|
|
+ ReadTimeout time.Duration // read timeout
|
|
|
}
|
|
|
|
|
|
type IHub interface {
|
|
|
Lock() // support locker semantics
|
|
|
Unlock()
|
|
|
|
|
|
- Wg() *sync.WaitGroup // object
|
|
|
- ChQuit() <-chan struct{} // 返回一个通道,用于退出 hub 循环
|
|
|
- Conf() *HubConfig // 返回配置信息
|
|
|
- Callback() ISessionCallback // 返回回调对象
|
|
|
- Protocol() IProtocol // 返回数据协议
|
|
|
+ Wg() *sync.WaitGroup // for waiting goroutines quit
|
|
|
+ ChQuit() <-chan struct{} // notify to quit
|
|
|
+ Conf() *HubConfig //
|
|
|
+ Callback() ISessionCallback // callback impl
|
|
|
+ Protocol() IProtocol // protocol impl
|
|
|
|
|
|
- Start() error // 启动 hub
|
|
|
- Stop() error // 停止 hub
|
|
|
- DoJob(int) // 执行 hub 中其他任务
|
|
|
+ Start() error // start hub
|
|
|
+ Stop() error // stop hub
|
|
|
+ DoJob(int) // not used now
|
|
|
|
|
|
- PutSession(uint64, ISession) error // session 管理,这里的 session 必须基于 id
|
|
|
+ PutSession(uint64, ISession) error // session management base on id
|
|
|
DelSession(uint64) error
|
|
|
GetSession(uint64) (ISession, error)
|
|
|
PeekSession(uint64) (ISession, error)
|