Draft: poop

This commit is contained in:
2025-11-10 13:16:29 +08:00
parent dbd2ed6469
commit 590687d968
12 changed files with 309 additions and 43 deletions

55
workflows/lobbyServer.go Normal file
View File

@@ -0,0 +1,55 @@
package workflows
import (
"fmt"
"inp2025/middlewares"
"inp2025/tcp"
"io"
"time"
"go.uber.org/zap"
)
func pongHandler(w tcp.ResponseWriter, req *tcp.Request) error {
w.WriteHeader(tcp.StatusOK)
_, err := io.WriteString(w, string(req.Params["msg"]))
return err
}
func tickHandler(w tcp.ResponseWriter, req *tcp.Request) error {
zap.L().Info("Run tickHandler")
for {
w.SocketSendString(fmt.Sprintf("time: %s", time.Now().String()))
time.Sleep(time.Second)
}
return nil
}
func LobbyServer() *tcp.Router {
router := tcp.NewRouter().
Use(middlewares.ErrorHandler).
Use(middlewares.AccessLog)
// test
test := router.Group("/test").
Use(middlewares.NMSL)
test.SOCKET("/tick", tickHandler)
test.GET("/ping", pongHandler)
/*
auth := router.Group("/auth")
auth.POST("/register")
auth.POST("/login")
auth.POST("/logout")
api := router.Group("/api")
api.GET("/online-users")
api.GET("/rooms")
api.GET("/invitations")
api.GET("/current-invitation")
api.POST("/invite")
api.POST("/accept-invitition")
*/
return router
}