Documentation
¶
Index ¶
- Constants
- func StartSessionListener(s *State)
- type KookSession
- type KookWsConn
- type State
- func (s *State) GetGateway(compress bool) error
- func (s *State) ReceiveData(data []byte) (error, []byte)
- func (s *State) RegisterEventHandler(handler []event.TypedEventHandler)
- func (s *State) Retry(event *fsm.Event, handler func() error, errorHandler func() error)
- func (s *State) Start()
- func (s *State) StartCheckHeartbeat() error
- func (s *State) WsConnect() error
- type StatusParam
Constants ¶
View Source
const ( StatusStart = "start" StatusInit = "init" StatusGateway = "gateway" StatusWSConnected = "wsConnected" StatusConnected = "connected" StatusRetry = "retry" )
View Source
const ( EventEnterPrefix = "enter_" EventStart = "fsmStart" EventGotGateway = "getGateWay" EventWsConnected = "wsConnect" EventWsConnectFail = "wsConnectFail" EventHelloReceived = "helloReceived" EventHelloFail = "helloFail" EventHelloGatewayErrFail = "helloGatewayErrFail" EventPongReceived = "pongReceived" EventHeartbeatTimeout = "heartbeatTimeout" EventRetryHeartbeatTimeout = "retryHeartbeatTimeout" EventResumeReceivedOk = "ResumeReceived" )
View Source
const ( InfiniteRetry = 0 NoRetry = -1 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KookSession ¶
func CreateSession ¶
func CreateSession(token string, compress bool) (*KookSession, error)
CreateSession 创建Session
func (*KookSession) RegisterEventHandler ¶
func (s *KookSession) RegisterEventHandler(handler event.TypedEventHandler)
func (*KookSession) RegisterEventHandlers ¶
func (s *KookSession) RegisterEventHandlers(handler []event.TypedEventHandler)
func (*KookSession) Start ¶
func (s *KookSession) Start()
type KookWsConn ¶
func (*KookWsConn) SendData ¶
func (c *KookWsConn) SendData(data []byte) error
type State ¶
type State struct {
Compress bool
Conn *KookWsConn
SessionId string
FSM *fsm.FSM // 状态机
StatusParams map[string]*StatusParam
PongTimeoutChan chan time.Time
LastPingAt time.Time
Timeout int
ReceiveQueue chan *model.Signal
HeartBeatPongChan chan bool
HeartBeatCron *gocron.Scheduler
MaxSN int
EventQueue *event.EventQueue
EventManager *event.EventManager
}
func CreateState ¶
func (*State) GetGateway ¶
func (*State) RegisterEventHandler ¶
func (s *State) RegisterEventHandler(handler []event.TypedEventHandler)
func (*State) StartCheckHeartbeat ¶
StartCheckHeartbeat 检查心跳
Click to show internal directories.
Click to hide internal directories.