Documentation ¶
Index ¶
- Constants
- func DefaultPackMessage(packetFormat string, messageType MessageType, userId UserId, deviceId DeviceId, ...) []byte
- type Config
- type Connection
- func (c *Connection) Close(code int, reason string)
- func (c *Connection) GetInfo() (ConnectionId, UserId, DeviceId)
- func (c *Connection) GetStartTime() time.Time
- func (c *Connection) IsClosed() bool
- func (c *Connection) IsLoggedIn() bool
- func (c *Connection) Login(userId UserId, deviceId DeviceId)
- func (c *Connection) ReadMessage() (messageType int, p []byte, err error)
- func (c *Connection) SendBinary(message []byte)
- func (c *Connection) SendText(message []byte)
- func (c *Connection) UpdateLastPingTime()
- type ConnectionId
- type ConnectionsStats
- type ConnectionsStorage
- func (s *ConnectionsStorage) AddNewConnection(connection *Connection)
- func (s *ConnectionsStorage) GetConnectionById(connectionId ConnectionId) *Connection
- func (s *ConnectionsStorage) GetDeviceConnection(deviceId DeviceId) *Connection
- func (s *ConnectionsStorage) GetStats() ConnectionsStats
- func (s *ConnectionsStorage) GetUserConnections(userId UserId) map[DeviceId]*Connection
- func (s *ConnectionsStorage) OnLogin(connection *Connection) *Connection
- func (s *ConnectionsStorage) RemoveConnection(connection *Connection)
- func (s *ConnectionsStorage) RemoveIf(condition func(con *Connection) bool, afterRemove func(con *Connection))
- type DeviceId
- type MessageType
- type NatsWebSocket
- type PackMessageFunc
- type Pool
- type UserId
Constants ¶
View Source
const (
LOGIN_PREFIX = "login>:"
)
Variables ¶
This section is empty.
Functions ¶
func DefaultPackMessage ¶
Types ¶
type Config ¶
type Config struct { ListenInterface string `json:"listenInterface"` UrlPattern string `json:"urlPattern"` PacketFormat string `json:"packetFormat"` JwtSecret string `json:"jwtSecret"` NatsAddress string `json:"natsAddress"` NatsPoolSize int `json:"natsPoolSize"` NatsListenSubject string `json:"natsListenSubject"` NatsOutputSubject string `json:"natsOutputSubject"` }
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection wraps user connection.
func NewConnection ¶
func NewConnection(id ConnectionId, ws *websocket.Conn) *Connection
func (*Connection) Close ¶
func (c *Connection) Close(code int, reason string)
func (*Connection) GetInfo ¶
func (c *Connection) GetInfo() (ConnectionId, UserId, DeviceId)
func (*Connection) GetStartTime ¶
func (c *Connection) GetStartTime() time.Time
func (*Connection) IsClosed ¶
func (c *Connection) IsClosed() bool
func (*Connection) IsLoggedIn ¶
func (c *Connection) IsLoggedIn() bool
func (*Connection) Login ¶
func (c *Connection) Login(userId UserId, deviceId DeviceId)
func (*Connection) ReadMessage ¶
func (c *Connection) ReadMessage() (messageType int, p []byte, err error)
func (*Connection) SendBinary ¶
func (c *Connection) SendBinary(message []byte)
func (*Connection) SendText ¶
func (c *Connection) SendText(message []byte)
func (*Connection) UpdateLastPingTime ¶
func (c *Connection) UpdateLastPingTime()
type ConnectionId ¶
type ConnectionId int64
type ConnectionsStats ¶
type ConnectionsStorage ¶
type ConnectionsStorage struct {
// contains filtered or unexported fields
}
func NewConnectionsStorage ¶
func NewConnectionsStorage() *ConnectionsStorage
func (*ConnectionsStorage) AddNewConnection ¶
func (s *ConnectionsStorage) AddNewConnection(connection *Connection)
func (*ConnectionsStorage) GetConnectionById ¶
func (s *ConnectionsStorage) GetConnectionById(connectionId ConnectionId) *Connection
func (*ConnectionsStorage) GetDeviceConnection ¶
func (s *ConnectionsStorage) GetDeviceConnection(deviceId DeviceId) *Connection
func (*ConnectionsStorage) GetStats ¶
func (s *ConnectionsStorage) GetStats() ConnectionsStats
func (*ConnectionsStorage) GetUserConnections ¶
func (s *ConnectionsStorage) GetUserConnections(userId UserId) map[DeviceId]*Connection
func (*ConnectionsStorage) OnLogin ¶
func (s *ConnectionsStorage) OnLogin(connection *Connection) *Connection
func (*ConnectionsStorage) RemoveConnection ¶
func (s *ConnectionsStorage) RemoveConnection(connection *Connection)
func (*ConnectionsStorage) RemoveIf ¶
func (s *ConnectionsStorage) RemoveIf(condition func(con *Connection) bool, afterRemove func(con *Connection))
type NatsWebSocket ¶
type NatsWebSocket struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *Config) *NatsWebSocket
func NewCustom ¶
func NewCustom(config *Config, packMessageHook PackMessageFunc) *NatsWebSocket
func (*NatsWebSocket) Start ¶
func (w *NatsWebSocket) Start()
func (*NatsWebSocket) Stop ¶
func (w *NatsWebSocket) Stop()
type PackMessageFunc ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package pb is a generated protocol buffer package.
|
Package pb is a generated protocol buffer package. |
Click to show internal directories.
Click to hide internal directories.