blasphem/pkg/server/websocket.go

28 lines
515 B
Go
Raw Normal View History

2022-09-25 11:42:36 -04:00
package server
import (
2022-12-19 19:24:01 -05:00
"dynatron.me/x/blasphem/pkg/wsapi"
2022-09-25 11:42:36 -04:00
"github.com/gorilla/websocket"
2022-09-30 14:37:40 -04:00
"github.com/labstack/echo/v4"
2022-12-19 19:24:01 -05:00
"github.com/rs/zerolog/log"
2022-09-25 11:42:36 -04:00
)
var upgrader = websocket.Upgrader{
2022-09-26 15:00:21 -04:00
ReadBufferSize: 1024,
2022-09-25 11:42:36 -04:00
WriteBufferSize: 1024,
}
2022-09-30 14:37:40 -04:00
func (s *Server) wsHandler(c echo.Context) error {
2022-12-19 19:24:01 -05:00
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()
2022-09-25 11:42:36 -04:00
}