Documentation
¶
Index ¶
- Constants
- func SendError(socket *websocket.Conn, err error) error
- func Upgrader(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)
- type Channel
- type Client
- type Hub
- func (s *Hub) Close()
- func (s *Hub) Connect(socket *websocket.Conn, ctx context.Context) (*Client, error)
- func (s *Hub) OnChannel(fn func(Channel))
- func (s *Hub) OnConnection(fn func(*Client))
- func (s *Hub) OnDisconnection(fn func(*Client))
- func (s *Hub) OnListener(fn func(*Client, []byte))
- func (s *Hub) OnPublish(fn func(ch Channel, ms Message))
- func (s *Hub) OnRemove(fn func(string))
- func (s *Hub) OnSend(fn func(to string, ms Message))
- func (s *Hub) Publish(channel string, message Message) ([]string, error)
- func (s *Hub) Queue(channel string) *Channel
- func (s *Hub) Remove(channel string) error
- func (s *Hub) SendTo(to []string, message Message) ([]string, error)
- func (s *Hub) SetDebug(debug bool)
- func (s *Hub) Stack(channel string) *Channel
- func (s *Hub) Start()
- func (s *Hub) Subscribe(channel string, subscribe string) error
- func (s *Hub) Topic(channel string) *Channel
- func (s *Hub) Unsubscribe(cache string, subscribe string) error
- type Message
- type Outbound
- type Status
- type TypeChannel
Constants ¶
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Channel ¶
type Channel struct {
Name string `json:"name"`
Type TypeChannel `json:"type"`
Subscribers []string `json:"subscribers"`
Turn int `json:"turn"`
}
type Client ¶
type Client struct {
Created_at time.Time `json:"created_at"`
Name string `json:"name"`
Addr string `json:"addr"`
Status Status `json:"status"`
Channels []string `json:"channels"`
// contains filtered or unexported fields
}
func (*Client) SendMessage ¶
func (s *Client) SendMessage(message interface{})
* * SendMessage * @param message interface{} *
type Hub ¶
type Hub struct {
Subscribers map[string]*Client `json:"subscribers"`
Channels map[string]*Channel `json:"channels"`
// contains filtered or unexported fields
}
func (*Hub) Connect ¶ added in v1.0.12
* * Connect * @param socket *websocket.Conn, context.Context * @return *Client, error *
func (*Hub) OnConnection ¶ added in v1.0.12
* * OnConnection * @param fn func(*Client) *
func (*Hub) OnDisconnection ¶ added in v1.0.12
* * OnDisconnection * @param fn func(*Client) *
func (*Hub) OnListener ¶ added in v1.0.15
* * OnListener * @param fn func(*Client, []byte) *
type Message ¶
type Message struct {
Created_at time.Time `json:"created_at"`
ID string `json:"id"`
From et.Json `json:"from"`
Channel string `json:"channel"`
To []string `json:"to"`
Ignored []string `json:"-"`
Message interface{} `json:"message"`
Verified bool `json:"verified"`
}
func DecodeMessage ¶
* * DecodeMessage * @param data []byte * @return Message, error *
func NewMessage ¶
* * NewMessage * @param from et.Json, to []string, data et.Json * @return *Message *
type TypeChannel ¶ added in v1.0.12
type TypeChannel string
const ( TpQueue TypeChannel = "Queue" TpStack TypeChannel = "Stack" TpTopic TypeChannel = "Topic" )
Click to show internal directories.
Click to hide internal directories.