wip: 0.2.3

1. websocket hook
  2. rtc init ok
This commit is contained in:
loveuer
2025-05-20 18:04:37 +08:00
parent becbc137c5
commit 16e9d663f4
9 changed files with 223 additions and 246 deletions

View File

@ -12,8 +12,8 @@ import (
func LocalRegister() nf.HandlerFunc {
return func(c *nf.Ctx) error {
type Req struct {
Candidate any `json:"candidate"`
Offer any `json:"offer"`
Candidate *controller.RoomCandidate `json:"candidate"`
Offer *controller.RoomOffer `json:"offer"`
}
var (
@ -74,3 +74,26 @@ func LocalWS() nf.HandlerFunc {
return nil
}
}
func LocalOffer() nf.HandlerFunc {
return func(c *nf.Ctx) error {
type Req struct {
Room string `json:"room"`
Id string `json:"id"`
Offer *controller.RoomOffer `json:"offer"`
}
var (
err error
req = new(Req)
)
if err = c.BodyParser(req); err != nil {
return c.Status(http.StatusBadRequest).JSON(map[string]string{"err": err.Error()})
}
controller.RoomController.Offer(req.Room, req.Id, req.Offer)
return resp.Resp200(c, req.Offer)
}
}