session

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

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

func StartSessionListener

func StartSessionListener(s *State)

listener

Types

type KookSession

type KookSession struct {
	Token string
	State *State
}

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

type KookWsConn struct {
	Url         string
	Token       string
	WebConn     *websocket.Conn
	WsWriteLock sync.Mutex
}

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 CreateState(compress bool) *State

func (*State) GetGateway

func (s *State) GetGateway(compress bool) error

func (*State) ReceiveData

func (s *State) ReceiveData(data []byte) (error, []byte)

func (*State) RegisterEventHandler

func (s *State) RegisterEventHandler(handler []event.TypedEventHandler)

func (*State) Retry

func (s *State) Retry(event *fsm.Event, handler func() error, errorHandler func() error)

func (*State) Start

func (s *State) Start()

func (*State) StartCheckHeartbeat

func (s *State) StartCheckHeartbeat() error

StartCheckHeartbeat 检查心跳

func (*State) WsConnect

func (s *State) WsConnect() error

type StatusParam

type StatusParam struct {
	StartTime  int
	MaxTime    int
	FirstDelay int
	Retry      int
	MaxRetry   int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL