rename WebSocket handler.

This commit is contained in:
Miroslav Šedivý 2021-08-29 23:01:51 +02:00
parent c82a083fb6
commit 402b8f1a08
2 changed files with 5 additions and 5 deletions

View File

@ -10,7 +10,7 @@ type WebSocketMessage struct {
Payload json.RawMessage `json:"payload"` Payload json.RawMessage `json:"payload"`
} }
type HandlerFunction func(Session, WebSocketMessage) bool type WebSocketHandler func(Session, WebSocketMessage) bool
type CheckOrigin func(r *http.Request) bool type CheckOrigin func(r *http.Request) bool
@ -22,6 +22,6 @@ type WebSocketPeer interface {
type WebSocketManager interface { type WebSocketManager interface {
Start() Start()
Shutdown() error Shutdown() error
AddHandler(handler HandlerFunction) AddHandler(handler WebSocketHandler)
Upgrade(w http.ResponseWriter, r *http.Request, checkOrigin CheckOrigin) Upgrade(w http.ResponseWriter, r *http.Request, checkOrigin CheckOrigin)
} }

View File

@ -28,7 +28,7 @@ func New(
sessions: sessions, sessions: sessions,
desktop: desktop, desktop: desktop,
handler: handler.New(sessions, desktop, capture, webrtc), handler: handler.New(sessions, desktop, capture, webrtc),
handlers: []types.HandlerFunction{}, handlers: []types.WebSocketHandler{},
} }
} }
@ -40,7 +40,7 @@ type WebSocketManagerCtx struct {
sessions types.SessionManager sessions types.SessionManager
desktop types.DesktopManager desktop types.DesktopManager
handler *handler.MessageHandlerCtx handler *handler.MessageHandlerCtx
handlers []types.HandlerFunction handlers []types.WebSocketHandler
} }
func (manager *WebSocketManagerCtx) Start() { func (manager *WebSocketManagerCtx) Start() {
@ -156,7 +156,7 @@ func (manager *WebSocketManagerCtx) Shutdown() error {
return nil return nil
} }
func (manager *WebSocketManagerCtx) AddHandler(handler types.HandlerFunction) { func (manager *WebSocketManagerCtx) AddHandler(handler types.WebSocketHandler) {
manager.handlers = append(manager.handlers, handler) manager.handlers = append(manager.handlers, handler)
} }