wip: v0.2.6
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user