Draft: poop
This commit is contained in:
55
workflows/lobbyServer.go
Normal file
55
workflows/lobbyServer.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user