Documentation
¶
Index ¶
- Constants
- func SendError(socket *websocket.Conn, err error) error
- func SendMessage(socket *websocket.Conn, message et.Json) error
- func Upgrader(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)
- type Channel
- type Hub
- func (s *Hub) Close()
- func (s *Hub) Connect(socket *websocket.Conn, ctx context.Context) (*Subscriber, error)
- func (s *Hub) OnChannel(fn func(Channel))
- func (s *Hub) OnConnection(fn func(*Subscriber))
- func (s *Hub) OnDisconnection(fn func(*Subscriber))
- 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 Subscriber
- type TypeChannel
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func SendError ¶ added in v1.0.14
* * SendError * @params socket *websocket.Conn, err error * @return error *
func SendMessage ¶ added in v1.0.14
* * SendMessage * @params socket *websocket.Conn, message et.Json * @return error *
Types ¶
type Channel ¶
type Channel struct {
Name string `json:"name"`
Type TypeChannel `json:"type"`
Subscribers []string `json:"subscribers"`
Turn int `json:"turn"`
}
type Hub ¶
type Hub struct {
Channels map[string]*Channel `json:"channels"`
Subscribers map[string]*Subscriber `json:"subscribers"`
// contains filtered or unexported fields
}
func (*Hub) Connect ¶ added in v1.0.12
* * Connect * @param socket *websocket.Conn, context.Context * @return *Subscriber, error *
func (*Hub) OnConnection ¶ added in v1.0.12
func (s *Hub) OnConnection(fn func(*Subscriber))
* * OnConnection * @param fn func(*Subscriber) *
func (*Hub) OnDisconnection ¶ added in v1.0.12
func (s *Hub) OnDisconnection(fn func(*Subscriber))
* * OnDisconnection * @param fn func(*Subscriber) *
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 messageType int, data []byte * @return Message *
func NewMessage ¶
* * NewMessage * @param from et.Json, to []string, data et.Json * @return *Message *
type Subscriber ¶
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.