Documentation ¶
Index ¶
- type Adapter
- func (a *Adapter) Close()
- func (a *Adapter) Command() string
- func (a *Adapter) Connection() *Connection
- func (a *Adapter) Context() NetContext
- func (a *Adapter) Data() []byte
- func (a *Adapter) JSONData(obj interface{}) error
- func (a *Adapter) RequestID() int64
- func (a *Adapter) Send(message interface{}) error
- func (a *Adapter) StringData() string
- func (a *Adapter) Subscribers(commands string) Connections
- func (a *Adapter) User() *User
- type Channel
- func (channel *Channel) AddConnectFunc(fn func(a *Adapter))
- func (channel *Channel) AddDisconnectFunc(fn func(a *Adapter))
- func (channel *Channel) Close()
- func (channel *Channel) Connection(connID uint64) *Connection
- func (channel *Channel) Count() int
- func (channel *Channel) GetConnects() (connectIDs map[uint64]*Connection)
- func (channel *Channel) GetUsers() (userIDs map[interface{}]*User)
- func (channel *Channel) Handler(conn ConnIface, context NetContext)
- func (channel *Channel) Read(command string, fn func(*Adapter))
- func (channel *Channel) Send(command string, message interface{}) error
- func (channel *Channel) Subscribers(commands string) Connections
- func (channel *Channel) User(userID interface{}) *User
- func (channel *Channel) UsersCount() int
- type Client
- func (c *Client) ChangeURL(url string)
- func (c *Client) Close()
- func (c *Client) Read(command string, fn func(*Adapter))
- func (c *Client) Request(command string, message interface{}, timeout ...time.Duration) ([]byte, error)
- func (c *Client) Send(command string, message interface{}, requestID ...int64) (err error)
- func (c *Client) Subscribe(command string)
- func (c *Client) UnSubscribe(command string)
- type ConnIface
- type Connection
- func (c *Connection) Close()
- func (c *Connection) Context() NetContext
- func (c *Connection) ID() uint64
- func (c *Connection) IsSubscribed(commands string) bool
- func (c *Connection) Origin() string
- func (c *Connection) Request(command string, message interface{}, timeout ...time.Duration) ([]byte, error)
- func (c *Connection) Send(command string, message interface{}, requestID ...int64) error
- func (c *Connection) Subscribe(command string)
- func (c *Connection) Subscribers(commands string) Connections
- func (c *Connection) User() *User
- type Connections
- type Map
- type NetContext
- type User
- func (u *User) Close()
- func (u *User) Connection(connID uint64) *Connection
- func (u *User) Count() int
- func (u *User) GetConnects() (connectIDs map[uint64]*Connection)
- func (u *User) ID() interface{}
- func (u *User) Send(command string, message interface{}) error
- func (u *User) Subscribers(commands string, message interface{}) Connections
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is slice of Connect instances
func (*Adapter) Connection ¶
func (a *Adapter) Connection() *Connection
Connection returns adapter connect instance
func (*Adapter) StringData ¶
StringData return string client message without json ""
func (*Adapter) Subscribers ¶
func (a *Adapter) Subscribers(commands string) Connections
Subscribers of commands ("command1,command2" etc.)
type Channel ¶
type Channel struct { UseBinary bool // contains filtered or unexported fields }
Channel is websocket route
func (*Channel) AddConnectFunc ¶
AddConnectFunc add new Connect handler
func (*Channel) AddDisconnectFunc ¶
AddDisconnectFunc add new Disconnect handler
func (*Channel) Connection ¶
func (channel *Channel) Connection(connID uint64) *Connection
Connection by ID (or empty closed if not found)
func (*Channel) GetConnects ¶
func (channel *Channel) GetConnects() (connectIDs map[uint64]*Connection)
GetConnects from Channel
func (*Channel) Handler ¶ added in v1.2.0
func (channel *Channel) Handler(conn ConnIface, context NetContext)
Handler add websocket handler
func (*Channel) Subscribers ¶
func (channel *Channel) Subscribers(commands string) Connections
Subscribers of commands ("command1,command2" etc.)
type Client ¶
Client ws instance
func (*Client) Request ¶
func (c *Client) Request(command string, message interface{}, timeout ...time.Duration) ([]byte, error)
Request information from server
func (*Client) UnSubscribe ¶ added in v1.2.7
UnSubscribe from command
type ConnIface ¶ added in v1.2.0
type ConnIface interface { SetReadLimit(limit int64) ReadMessage() (messageType int, p []byte, err error) WriteMessage(messageType int, data []byte) error Close() error }
Channel is websocket route
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection instance [Copying Connection by value is forbidden. Use pointer to Connection instead.]
func (*Connection) Context ¶
func (c *Connection) Context() NetContext
Context returns copy of NetContext
func (*Connection) IsSubscribed ¶
func (c *Connection) IsSubscribed(commands string) bool
IsSubscribed returns true if Connect subscribed for one of commands ("command1,command2" etc.)
func (*Connection) Request ¶
func (c *Connection) Request(command string, message interface{}, timeout ...time.Duration) ([]byte, error)
Request information from client
func (*Connection) Send ¶
func (c *Connection) Send(command string, message interface{}, requestID ...int64) error
Send message to open connect
func (*Connection) Subscribe ¶
func (c *Connection) Subscribe(command string)
Subscribe connection to command
func (*Connection) Subscribers ¶
func (c *Connection) Subscribers(commands string) Connections
Subscribers returns Connects Subscribers of commands ("command1,command2" etc.)
type Connections ¶
type Connections struct {
// contains filtered or unexported fields
}
Connections is slice of Connect instances
func (Connections) Connection ¶
func (cs Connections) Connection(connID uint64) *Connection
Connection by ID (or empty closed if not found)
func (Connections) Send ¶
func (cs Connections) Send(command string, message interface{}) error
Send message to open connect
func (Connections) Subscribers ¶
func (cs Connections) Subscribers(commands string) Connections
Subscribers of commands ("command1,command2" etc.)
type NetContext ¶
type NetContext interface{}
NetContext is used network context, like *tokay.Context, *gin.Context, echo.Context etc.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User instance
func (*User) Connection ¶
func (u *User) Connection(connID uint64) *Connection
Connection by ID (or empty closed if not found)
func (*User) GetConnects ¶
func (u *User) GetConnects() (connectIDs map[uint64]*Connection)
GetConnects returns User connections
func (*User) Subscribers ¶
func (u *User) Subscribers(commands string, message interface{}) Connections
Subscribers of commands ("command1,command2" etc.)