Documentation ¶
Index ¶
- Variables
- type MessageHandler
- type Socket
- type Subprotocol
- func (s *Subprotocol) Broadcast(topic string, payload []byte) error
- func (s *Subprotocol) Handle(topic string, handler MessageHandler)
- func (s *Subprotocol) JoinRoom(name string, socket *Socket)
- func (s *Subprotocol) LeaveRoom(name string, socket *Socket)
- func (s *Subprotocol) SendToClient(id string, topic string, payload []byte) error
- func (s *Subprotocol) SendToRoom(name string, topic string, payload []byte) error
- func (s *Subprotocol) SendToSocket(socket *Socket, topic string, payload []byte) error
- type WebSocketServer
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrMessageTooLong = errors.New("websocket: message too long")
)
Functions ¶
This section is empty.
Types ¶
type MessageHandler ¶
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
type Subprotocol ¶
type Subprotocol struct { FallbackHandler func(socket *Socket, message string, payload []byte) ClientID func(r *http.Request) (clientID string) // contains filtered or unexported fields }
func (*Subprotocol) Handle ¶
func (s *Subprotocol) Handle(topic string, handler MessageHandler)
Handle defines the handler for a message. Handlers are not called concurrently and will block further messages from being handled on the same Socket to ensure message ordering.
func (*Subprotocol) JoinRoom ¶
func (s *Subprotocol) JoinRoom(name string, socket *Socket)
func (*Subprotocol) LeaveRoom ¶
func (s *Subprotocol) LeaveRoom(name string, socket *Socket)
func (*Subprotocol) SendToClient ¶
func (s *Subprotocol) SendToClient(id string, topic string, payload []byte) error
func (*Subprotocol) SendToRoom ¶
func (s *Subprotocol) SendToRoom(name string, topic string, payload []byte) error
func (*Subprotocol) SendToSocket ¶
func (s *Subprotocol) SendToSocket(socket *Socket, topic string, payload []byte) error
type WebSocketServer ¶
type WebSocketServer struct {
// contains filtered or unexported fields
}
func NewWebSocketServer ¶
func NewWebSocketServer() *WebSocketServer
func (*WebSocketServer) ServeHTTP ¶
func (ws *WebSocketServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface
func (*WebSocketServer) SetLogger ¶
func (ws *WebSocketServer) SetLogger(logger *logrus.Entry)
func (*WebSocketServer) Subprotocol ¶
func (ws *WebSocketServer) Subprotocol(name string) (subp *Subprotocol)
Click to show internal directories.
Click to hide internal directories.