Documentation ¶
Index ¶
- Constants
- type Client
- type Hub
- func (h *Hub) AddClient(client *Client)
- func (h *Hub) Broadcast(message []byte)
- func (h *Hub) Clients() (clients []*Client)
- func (h *Hub) GetClientByIdAndType(clientId, clientType string) (client *Client, err error)
- 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) UnSubscribe(command string)
- type Message
- type StreamService
- func (s *StreamService) Broadcast(message []byte)
- func (s *StreamService) GetClientByIdAndType(clientId, clientType string) (client *Client, err error)
- 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 ( ClientTypeServer = "server" ClientTypeMobile = "mobile" )
View Source
const ( Request = "request" Response = "response" StatusSuccess = "success" StatusError = "error" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Hub ¶
func (*Hub) GetClientByIdAndType ¶
func (*Hub) UnSubscribe ¶
type Message ¶
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 ¶
type StreamService ¶
type StreamService struct { Hub *Hub // contains filtered or unexported fields }
func NewStreamService ¶
func NewStreamService(hub *Hub, adaptors *adaptors.Adaptors) *StreamService
func (*StreamService) Broadcast ¶
func (s *StreamService) Broadcast(message []byte)
func (*StreamService) GetClientByIdAndType ¶
func (s *StreamService) GetClientByIdAndType(clientId, clientType string) (client *Client, err error)
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.