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() 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 }