package controller

import (
	"context"

	"github.com/gogf/gf/v2/frame/g"

	"cris/api/v1/common"
	"cris/internal/service"
)

type WebsocketController struct {
	WebsocketService *service.WebsocketService
}

func (c *WebsocketController) Websocket(ctx context.Context, req *common.ChatReq) (res *common.LoginRes, err error) {
	r := g.RequestFromCtx(ctx)
	if err := r.Parse(req); err != nil {
		r.Response.WriteJsonExit(g.Map{"error": err.Error()})
	}

	c.WebsocketService.WebSocket(r, req)
	return nil, nil
}
