| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package nnet
- import (
- "sync"
- "time"
- )
- var (
- //
- DefHubConfig = HubConfig{
- SizeOfSendChan: 1024,
- SizeOfRecvChan: 1024,
- ReadBufSize: 2048,
- WriteBufSize: 2048,
- Timeout: 3 * time.Second,
- Tick: 10 * time.Second,
- ReadTimeout: 12 * time.Second, // should greater than Tick
- }
- )
- type HubConfig struct {
- SizeOfSendChan uint32
- SizeOfRecvChan uint32
- 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 // for waiting goroutines quit
- ChQuit() <-chan struct{} // notify to quit
- Conf() *HubConfig //
- Callback() ISessionCallback // callback impl
- Protocol() IProtocol // protocol impl
- Start() error // start hub
- Stop() error // stop hub
- DoJob(int) // not used now
- NewConnection(string, uint64) error
- StartReconn(string, uint64)
- PutSession(uint64, ISession) error // session management base on id
- DelSession(uint64) error
- GetSession(uint64) (ISession, error)
- PeekSession(uint64) (ISession, error)
- RandSession() (ISession, error)
- GetSessionNum() int
- GetAllSessions() map[uint64]ISession
- }
|