Documentation ¶
Index ¶
- type Client
- type Handler
- type Message
- type Server
- func (s *Server) ProcessMessage(conn *websocket.Conn, clientID string, msg []byte) *Server
- func (s *Server) Publish(topic string, message []byte)
- func (s *Server) RemoveClient(clientID string)
- func (s *Server) Send(conn *websocket.Conn, message string)
- func (s *Server) SendWithWait(conn *websocket.Conn, message string, wg *sync.WaitGroup)
- func (s *Server) Subscribe(conn *websocket.Conn, clientID string, topic string)
- func (s *Server) Unsubscribe(clientID string, topic string)
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct { Action string `json:"action"` Topic string `json:"topic"` Message string `json:"message"` }
Message is a struct for message to be sent by the client
type Server ¶
type Server struct {
Subscriptions Subscription
}
Server is the struct to handle the Server functions & manage the Subscriptions
func (*Server) ProcessMessage ¶
ProcessMessage handle message according to the action type
func (*Server) RemoveClient ¶
RemoveClient removes the clients from the server subscription map
func (*Server) SendWithWait ¶
SendWithWait sends message to the websocket client using wait group, allowing usage with goroutines
func (*Server) Unsubscribe ¶
Unsubscribe removes a clients from a topic's client map
type Subscription ¶
Subscription is a type for each string of topic and the clients that subscribe to it
Click to show internal directories.
Click to hide internal directories.