wip: v0.2.6

This commit is contained in:
loveuer
2025-05-26 09:37:23 +08:00
parent b8645a68ed
commit 5bc695bde3
10 changed files with 141 additions and 146 deletions

View File

@ -9,6 +9,19 @@ import (
"net/http"
)
func LocalRegister() nf.HandlerFunc {
return func(c *nf.Ctx) error {
var (
ip = c.IP(true)
ua = c.Get("User-Agent")
)
client := controller.RoomController.Register(ip, ua)
return resp.Resp200(c, client)
}
}
func LocalClients() nf.HandlerFunc {
return func(c *nf.Ctx) error {
list := controller.RoomController.List()
@ -27,10 +40,11 @@ func LocalWS() nf.HandlerFunc {
}
return func(c *nf.Ctx) error {
var (
ip = c.IP(true)
ua = c.Get("User-Agent")
)
id := c.Query("id")
if id == "" {
return c.Status(http.StatusBadRequest).JSON(map[string]string{"error": "id is empty"})
}
conn, err := upgrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
@ -38,7 +52,7 @@ func LocalWS() nf.HandlerFunc {
return err
}
controller.RoomController.Register(conn, ip, ua)
controller.RoomController.Enter(conn, id)
return nil
}