27 lines
515 B
Go
27 lines
515 B
Go
package server
|
|
|
|
import (
|
|
"dynatron.me/x/blasphem/pkg/wsapi"
|
|
|
|
"github.com/gorilla/websocket"
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
var upgrader = websocket.Upgrader{
|
|
ReadBufferSize: 1024,
|
|
WriteBufferSize: 1024,
|
|
}
|
|
|
|
func (s *Server) wsHandler(c echo.Context) error {
|
|
conn, err := upgrader.Upgrade(c.Response(), c.Request(), nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
defer conn.Close()
|
|
|
|
log.Debug().Str("remote", c.Request().RemoteAddr).Msg("WS")
|
|
|
|
return wsapi.New(s, c, conn).Handle()
|
|
}
|