Documentation ¶
Index ¶
- Constants
- func DecodeWSMessage(msg string) map[string]interface{}
- type ConnectionManager
- 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 ¶
Types ¶
type ConnectionManager ¶
type ConnectionManager interface { Save(wsConnection *WSConnection) Get() *WSConnection Close() error }
type LobbyWebSocketClient ¶
type LobbyWebSocketClient struct {
WSConn *WSConnection
}
LobbyWebSocketClient is the extended implementation of ConnectionManagerImpl
func NewLobbyWebSocketClient ¶
func NewLobbyWebSocketClient(wsConn *WSConnection) *LobbyWebSocketClient
func (*LobbyWebSocketClient) ClearData ¶
func (c *LobbyWebSocketClient) ClearData()
func (*LobbyWebSocketClient) Close ¶
func (c *LobbyWebSocketClient) Close() error
func (*LobbyWebSocketClient) Connect ¶
func (c *LobbyWebSocketClient) Connect(reconnecting bool) (bool, error)
func (*LobbyWebSocketClient) Get ¶
func (c *LobbyWebSocketClient) Get() *WSConnection
func (*LobbyWebSocketClient) GetData ¶
func (c *LobbyWebSocketClient) GetData(key string) interface{}
func (*LobbyWebSocketClient) HasData ¶
func (c *LobbyWebSocketClient) HasData(key string) bool
func (*LobbyWebSocketClient) OnConnect ¶
func (c *LobbyWebSocketClient) OnConnect(reconnecting bool)
func (*LobbyWebSocketClient) OnDisconnect ¶
func (c *LobbyWebSocketClient) OnDisconnect(code int32, reason string)
func (*LobbyWebSocketClient) OnMessage ¶
func (c *LobbyWebSocketClient) OnMessage(msg string)
func (*LobbyWebSocketClient) ReadWSMessage ¶
func (c *LobbyWebSocketClient) ReadWSMessage(done chan struct{}, messageHandler func(message []byte))
func (*LobbyWebSocketClient) ReconnectDelay ¶
func (c *LobbyWebSocketClient) ReconnectDelay(numberOfAttempts int32) float32
func (*LobbyWebSocketClient) Save ¶
func (c *LobbyWebSocketClient) Save(conn *WSConnection)
func (*LobbyWebSocketClient) Send ¶
func (c *LobbyWebSocketClient) Send(code int, message string) error
func (*LobbyWebSocketClient) SetData ¶
func (c *LobbyWebSocketClient) SetData(key string, value interface{})
func (*LobbyWebSocketClient) ShouldReconnect ¶
func (c *LobbyWebSocketClient) ShouldReconnect(code int, reason string, numberOfAttempts int) bool
func (*LobbyWebSocketClient) WSHeartbeat ¶
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 ¶
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) DefaultCloseHandler ¶
func (c *WSConnection) DefaultCloseHandler(code int, reason string) error
func (*WSConnection) DefaultPongHandler ¶
func (c *WSConnection) DefaultPongHandler(text string) error
func (*WSConnection) GetData ¶
func (c *WSConnection) GetData(key string) interface{}
func (*WSConnection) GetStatus ¶
func (c *WSConnection) GetStatus() string
func (*WSConnection) SetStatus ¶
func (c *WSConnection) SetStatus(status string)
type WSConnectionMessageHandler ¶
type WSConnectionMessageHandler func(msg []byte)
type WSConnectionOption ¶
type WSConnectionOption func(wsConn *WSConnection) error
func WithEnableAutoReconnect ¶
func WithEnableAutoReconnect() WSConnectionOption
func WithMaxReconnectAttempts ¶
func WithMaxReconnectAttempts(maxReconnectAttempts int) WSConnectionOption
func WithMessageHandler ¶
func WithMessageHandler(handler WSConnectionMessageHandler) WSConnectionOption
Click to show internal directories.
Click to hide internal directories.