Documentation
¶
Index ¶
- Constants
- type GateWayHttpApiResult
- type Session
- type SessionInterface
- type State
- type StateSession
- func (s *StateSession) GetGateway() error
- func (s *StateSession) ReceiveFrameHandler(frame *event2.FrameMap) (error, []byte)
- func (s *StateSession) Reconnect()
- func (s *StateSession) ResumeOk()
- func (s *StateSession) Retry(e *fsm.Event, handler func() error, errHandler func() error)
- func (s *StateSession) RetryHeartbeat() error
- func (s *StateSession) SaveSessionId(sessionId string)
- func (s *StateSession) SendHeartBeat() error
- func (s *StateSession) Start()
- func (s *StateSession) StartCheckHeartbeat()
- func (s *StateSession) StartHeartbeat() error
- func (s *StateSession) StartProcessEvent()
- func (s *StateSession) WsConnect() error
- type StatusParam
- type SystemInterface
- type WebSocketSession
- type WebhookSession
Constants ¶
View Source
const ( // 默认开始状态 StatusStart = "start" // 初始状态 StatusInit = "init" // 网关已获取 StatusGateway = "gateway" // ws已经连接,等待hello包 StatusWSConnected = "ws_connected" //已连接状态 StatusConnected = "connected" //resume 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 ( NO_RETRY = -1 RETRY_INFINIT = 0 )
View Source
const EventDataFrameKey = "frame"
View Source
const EventDataSessionKey = "session"
View Source
const EventReceiveFrame = "EVENT-GLOBAL-RECEIVE_FRAME"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GateWayHttpApiResult ¶
type Session ¶
type Session struct { Compressed int ReceiveFrameHandler func(frame *event2.FrameMap) (error, []byte) ProcessDataHandler func(data []byte) (error, []byte) EventSyncHandle bool }
func (*Session) ReceiveFrame ¶
type SessionInterface ¶
type StateSession ¶
type StateSession struct { Session SessionId string //Status string GateWay string Timeout int RecvQueue chan *event2.FrameMap MaxSn int64 FSM *fsm.FSM NetworkProxy SystemInterface StatusParams map[string]*StatusParam HeartBeatCron *cron.Cron LastPongAt time.Time LastPingAt time.Time PongTimeoutChan chan time.Time }
* _________________
- 获取gateWay 连接ws 收到hello | 心跳超时 |
- | | | | | |
- v v v | V |
- INIT --> GATEWAY --> WS_CONNECTED --> CONNECTED --> RETRY |
- ^ | ^ | ^_______| |
- | | |_____________|__________________________| |
- | | | | |
- |________|_________________|__________________________|____| *
func NewStateSession ¶
func NewStateSession(gateway string, compressed int) *StateSession
func (*StateSession) GetGateway ¶
func (s *StateSession) GetGateway() error
func (*StateSession) ReceiveFrameHandler ¶
func (s *StateSession) ReceiveFrameHandler(frame *event2.FrameMap) (error, []byte)
func (*StateSession) Reconnect ¶
func (s *StateSession) Reconnect()
func (*StateSession) ResumeOk ¶
func (s *StateSession) ResumeOk()
func (*StateSession) Retry ¶
func (s *StateSession) Retry(e *fsm.Event, handler func() error, errHandler func() error)
func (*StateSession) RetryHeartbeat ¶
func (s *StateSession) RetryHeartbeat() error
func (*StateSession) SaveSessionId ¶
func (s *StateSession) SaveSessionId(sessionId string)
func (*StateSession) SendHeartBeat ¶
func (s *StateSession) SendHeartBeat() error
func (*StateSession) Start ¶
func (s *StateSession) Start()
func (*StateSession) StartCheckHeartbeat ¶
func (s *StateSession) StartCheckHeartbeat()
func (*StateSession) StartHeartbeat ¶
func (s *StateSession) StartHeartbeat() error
func (*StateSession) StartProcessEvent ¶
func (s *StateSession) StartProcessEvent()
func (*StateSession) WsConnect ¶
func (s *StateSession) WsConnect() error
WsConnect : Try to websocket connect
type StatusParam ¶
type SystemInterface ¶
type WebSocketSession ¶
type WebSocketSession struct { *StateSession Token string BaseUrl string SessionFile string WsConn *websocket.Conn WsWriteLock *sync.Mutex ReqGateway func() (error, string) }
func NewWebSocketSession ¶
func NewWebSocketSession(token, baseUrl, sessionFile, gateWay string, compressed int) *WebSocketSession
func (*WebSocketSession) ConnectWebsocket ¶
func (ws *WebSocketSession) ConnectWebsocket(gateway string) error
func (*WebSocketSession) ReqGateWay ¶
func (ws *WebSocketSession) ReqGateWay() (error, string)
func (*WebSocketSession) SaveSessionId ¶
func (ws *WebSocketSession) SaveSessionId(sessionId string) error
func (*WebSocketSession) SendData ¶
func (ws *WebSocketSession) SendData(data []byte) error
func (*WebSocketSession) Start ¶
func (ws *WebSocketSession) Start()
type WebhookSession ¶
func NewWebhookSession ¶
func NewWebhookSession(encryptKey, verityToken string, compress int) *WebhookSession
func (*WebhookSession) ProcessData ¶
func (s *WebhookSession) ProcessData(data []byte) (err error, data2 []byte)
func (*WebhookSession) ReceiveFrameHandler ¶
func (s *WebhookSession) ReceiveFrameHandler(frame *event2.FrameMap) (error, []byte)
func (*WebhookSession) SendData ¶
func (s *WebhookSession) SendData(data []byte) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.