neko/internal/types/websocket.go

28 lines
524 B
Go
Raw Normal View History

package types
2021-08-30 09:00:51 +12:00
import (
"encoding/json"
"net/http"
)
2021-08-30 09:00:51 +12:00
type WebSocketMessage struct {
Event string `json:"event"`
Payload json.RawMessage `json:"payload"`
}
2021-08-30 09:01:51 +12:00
type WebSocketHandler func(Session, WebSocketMessage) bool
2020-12-13 06:37:19 +13:00
2021-01-24 06:18:14 +13:00
type CheckOrigin func(r *http.Request) bool
2020-11-26 06:36:33 +13:00
type WebSocketPeer interface {
Send(v interface{}) error
2021-08-30 05:17:10 +12:00
Destroy()
}
2020-11-02 04:09:48 +13:00
type WebSocketManager interface {
2020-10-29 08:29:18 +13:00
Start()
Shutdown() error
2021-08-30 09:01:51 +12:00
AddHandler(handler WebSocketHandler)
2021-03-16 22:45:22 +13:00
Upgrade(w http.ResponseWriter, r *http.Request, checkOrigin CheckOrigin)
}