Documentation ¶
Index ¶
- Constants
- type Client
- type ClientType
- type Hub
- func (h *Hub) AddClient(client *Client)
- func (h *Hub) GetClientServer(clientId string) (client *Client, err error)
- func (h *Hub) GetCommandFromSubscribers(cmd string) func(client *Client, msg Message)
- func (h *Hub) GetServer(cli *Client) (server *Client, err error)
- func (h *Hub) GetServerClients(cli *Client) (clients []*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) Shutdown()
- func (h *Hub) Subscribe(command string, f func(client *Client, msg Message))
- func (h *Hub) UnSubscribe(command string)
- type Message
- type Stat
- type StreamService
Constants ¶
View Source
const ( Request = "request" Response = "response" StatusSuccess = "success" StatusError = "error" )
View Source
const ( ClientTypeServer = ClientType("server") ClientTypeMobile = ClientType("mobile") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Stat Id string Connect *websocket.Conn Ip string Send chan []byte Token string Type ClientType // contains filtered or unexported fields }
type ClientType ¶ added in v0.0.6
type ClientType string
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func NewHub ¶
func NewHub(adaptors *adaptors.Adaptors, graceful_service *graceful_service.GracefulService) *Hub
func (*Hub) GetClientServer ¶ added in v0.0.6
func (*Hub) GetCommandFromSubscribers ¶ added in v0.0.6
func (*Hub) GetServerClients ¶ added in v0.0.6
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) GetClientByIdAndType ¶
func (s *StreamService) GetClientByIdAndType(clientId string, clientType ClientType) (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.