Documentation ¶
Index ¶
- Constants
- func DecodeWSMessage(msg string) map[string]interface{}
- type ConnectionManager
- type ConnectionStatus
- type LobbyWebSocketClient
- func (c *LobbyWebSocketClient) ClearData()
- func (c *LobbyWebSocketClient) Close() error
- func (c *LobbyWebSocketClient) Connect(reconnecting bool) (bool, error)
- func (c *LobbyWebSocketClient) Get() *WSConnection
- func (c *LobbyWebSocketClient) GetData(key string) interface{}
- func (c *LobbyWebSocketClient) HasData(key string) bool
- func (c *LobbyWebSocketClient) OnConnect(reconnecting bool)
- func (c *LobbyWebSocketClient) OnDisconnect(code int32, reason string)
- func (c *LobbyWebSocketClient) OnMessage(msg string)
- func (c *LobbyWebSocketClient) ReadWSMessage(done chan struct{}, messageHandler func(message []byte))
- func (c *LobbyWebSocketClient) ReconnectDelay(numberOfAttempts int32) float32
- func (c *LobbyWebSocketClient) Save(conn *WSConnection)
- func (c *LobbyWebSocketClient) Send(code int, message string) error
- func (c *LobbyWebSocketClient) SetData(key string, value interface{})
- func (c *LobbyWebSocketClient) ShouldReconnect(code int, reason string, numberOfAttempts int) bool
- func (c *LobbyWebSocketClient) WSHeartbeat(done chan struct{})
- type WSConnection
- func (c *WSConnection) Close(code int, reason string) error
- func (c *WSConnection) DefaultCloseHandler(code int, reason string) error
- func (c *WSConnection) DefaultPongHandler(text string) error
- func (c *WSConnection) Dial(url string, headers http.Header) (*websocket.Conn, error)
- func (c *WSConnection) GetData(key string) interface{}
- func (c *WSConnection) GetStatus() string
- func (c *WSConnection) SetStatus(status string)
- type WSConnectionMessageHandler
- type WSConnectionOption
Constants ¶
View Source
const ( Disconnected = "Disconnected" Connecting = "Connecting" Connected = "Connected" Reconnecting = "Reconnecting" Closed = "Closed" )
View Source
const (
LobbySessionID = "lobbySessionID"
)
Variables ¶
This section is empty.
Functions ¶
func DecodeWSMessage ¶ added in v0.73.0
Types ¶
type ConnectionManager ¶
type ConnectionManager interface { Save(wsConnection *WSConnection) Get() *WSConnection Close() error }
type ConnectionStatus ¶ added in v0.73.0
type ConnectionStatus string
type LobbyWebSocketClient ¶ added in v0.73.0
type LobbyWebSocketClient struct {
WSConn *WSConnection
}
LobbyWebSocketClient is the extended implementation of ConnectionManagerImpl
func NewLobbyWebSocketClient ¶ added in v0.73.0
func NewLobbyWebSocketClient(wsConn *WSConnection) *LobbyWebSocketClient
func (*LobbyWebSocketClient) ClearData ¶ added in v0.73.0
func (c *LobbyWebSocketClient) ClearData()
func (*LobbyWebSocketClient) Close ¶ added in v0.73.0
func (c *LobbyWebSocketClient) Close() error
func (*LobbyWebSocketClient) Connect ¶ added in v0.73.0
func (c *LobbyWebSocketClient) Connect(reconnecting bool) (bool, error)
func (*LobbyWebSocketClient) Get ¶ added in v0.73.0
func (c *LobbyWebSocketClient) Get() *WSConnection
func (*LobbyWebSocketClient) GetData ¶ added in v0.73.0
func (c *LobbyWebSocketClient) GetData(key string) interface{}
func (*LobbyWebSocketClient) HasData ¶ added in v0.73.0
func (c *LobbyWebSocketClient) HasData(key string) bool
func (*LobbyWebSocketClient) OnConnect ¶ added in v0.73.0
func (c *LobbyWebSocketClient) OnConnect(reconnecting bool)
func (*LobbyWebSocketClient) OnDisconnect ¶ added in v0.73.0
func (c *LobbyWebSocketClient) OnDisconnect(code int32, reason string)
func (*LobbyWebSocketClient) OnMessage ¶ added in v0.73.0
func (c *LobbyWebSocketClient) OnMessage(msg string)
func (*LobbyWebSocketClient) ReadWSMessage ¶ added in v0.73.0
func (c *LobbyWebSocketClient) ReadWSMessage(done chan struct{}, messageHandler func(message []byte))
func (*LobbyWebSocketClient) ReconnectDelay ¶ added in v0.73.0
func (c *LobbyWebSocketClient) ReconnectDelay(numberOfAttempts int32) float32
func (*LobbyWebSocketClient) Save ¶ added in v0.73.0
func (c *LobbyWebSocketClient) Save(conn *WSConnection)
func (*LobbyWebSocketClient) Send ¶ added in v0.73.0
func (c *LobbyWebSocketClient) Send(code int, message string) error
func (*LobbyWebSocketClient) SetData ¶ added in v0.73.0
func (c *LobbyWebSocketClient) SetData(key string, value interface{})
func (*LobbyWebSocketClient) ShouldReconnect ¶ added in v0.73.0
func (c *LobbyWebSocketClient) ShouldReconnect(code int, reason string, numberOfAttempts int) bool
func (*LobbyWebSocketClient) WSHeartbeat ¶ added in v0.73.0
func (c *LobbyWebSocketClient) WSHeartbeat(done chan struct{})
type WSConnection ¶
type WSConnection struct { Conn *websocket.Conn Mu sync.RWMutex MuStatus sync.RWMutex Header http.Header Data map[string]interface{} EnableAutoReconnect bool MaxReconnectAttempts int MessageHandler WSConnectionMessageHandler // contains filtered or unexported fields }
func NewWSConnection ¶ added in v0.73.0
func NewWSConnection( configRepo repository.ConfigRepository, tokenRepo repository.TokenRepository, options ...WSConnectionOption, ) (*WSConnection, error)
func NewWebsocketConnection ¶
func NewWebsocketConnection( configRepo repository.ConfigRepository, tokenRepo repository.TokenRepository, messageHandler func(msg []byte), ) (*WSConnection, error)
NewWebsocketConnection Deprecated: use NewWSConnection instead
func (*WSConnection) Close ¶ added in v0.73.0
func (c *WSConnection) Close(code int, reason string) error
func (*WSConnection) DefaultCloseHandler ¶ added in v0.73.0
func (c *WSConnection) DefaultCloseHandler(code int, reason string) error
func (*WSConnection) DefaultPongHandler ¶ added in v0.73.0
func (c *WSConnection) DefaultPongHandler(text string) error
func (*WSConnection) GetData ¶ added in v0.73.0
func (c *WSConnection) GetData(key string) interface{}
func (*WSConnection) GetStatus ¶ added in v0.73.0
func (c *WSConnection) GetStatus() string
func (*WSConnection) SetStatus ¶ added in v0.73.0
func (c *WSConnection) SetStatus(status string)
type WSConnectionMessageHandler ¶ added in v0.73.0
type WSConnectionMessageHandler func(msg []byte)
type WSConnectionOption ¶ added in v0.73.0
type WSConnectionOption func(wsConn *WSConnection) error
func WithEnableAutoReconnect ¶ added in v0.73.0
func WithEnableAutoReconnect() WSConnectionOption
func WithMaxReconnectAttempts ¶ added in v0.73.0
func WithMaxReconnectAttempts(maxReconnectAttempts int) WSConnectionOption
func WithMessageHandler ¶ added in v0.73.0
func WithMessageHandler(handler WSConnectionMessageHandler) WSConnectionOption
Click to show internal directories.
Click to hide internal directories.