Documentation ¶
Index ¶
- Constants
- type BroadcastClient
- type Client
- type ConnectType
- type Hub
- func (h *Hub) AddClient(client *Client)
- func (h *Hub) Broadcast(message []byte)
- func (h *Hub) Clients() (clients []*Client)
- func (h *Hub) Recv(client *Client, b []byte)
- func (h *Hub) Run()
- func (h *Hub) Send(client *Client, message []byte)
- func (h *Hub) Subscribe(command string, f func(client *Client, msg Message))
- func (h *Hub) Subscriber(command string) (f func(client *Client, msg Message))
- func (h *Hub) UnSubscribe(command string)
- type Message
- type StreamService
- func (s *StreamService) AddClient(client *Client)
- func (s *StreamService) Broadcast(message []byte)
- func (w *StreamService) GateClient(client BroadcastClient)
- func (s *StreamService) Subscribe(command string, f func(client *Client, msg Message))
- func (s *StreamService) UnSubscribe(command string)
- func (w *StreamService) Ws(ctx *gin.Context)
Constants ¶
View Source
const ( Request = "request" Response = "response" StatusSuccess = "success" StatusError = "error" Notify = "notify" Broadcast = "broadcast" )
View Source
const (
WEBSOCK = ConnectType("websock")
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastClient ¶ added in v0.0.15
type BroadcastClient interface {
Broadcast(message []byte)
}
type Client ¶
type Client struct { ConnType ConnectType Connect *websocket.Conn Ip string Referer string UserAgent string Width int Height int Cookie bool Language string Platform string Location string Href string // message buffered channel Send chan []byte }
func (*Client) UpdateInfo ¶
type ConnectType ¶
type ConnectType string
type Hub ¶
func (*Hub) Subscriber ¶ added in v0.0.15
func (*Hub) UnSubscribe ¶
type Message ¶ added in v0.0.9
type Message struct { Id uuid.UUID `json:"id"` Command string `json:"command"` Payload map[string]interface{} `json:"payload"` Forward string `json:"forward"` Status string `json:"status"` Type string `json:"type"` }
func NewMessage ¶ added in v0.0.9
type StreamService ¶
type StreamService struct {
Hub *Hub
}
func NewStreamService ¶
func NewStreamService(hub *Hub) *StreamService
func (*StreamService) AddClient ¶
func (s *StreamService) AddClient(client *Client)
func (*StreamService) Broadcast ¶
func (s *StreamService) Broadcast(message []byte)
func (*StreamService) GateClient ¶ added in v0.0.15
func (w *StreamService) GateClient(client BroadcastClient)
func (*StreamService) Subscribe ¶
func (s *StreamService) Subscribe(command string, f func(client *Client, msg Message))
func (*StreamService) UnSubscribe ¶
func (s *StreamService) UnSubscribe(command string)
func (*StreamService) Ws ¶
func (w *StreamService) Ws(ctx *gin.Context)
Click to show internal directories.
Click to hide internal directories.