Groundwork for handler that allows reconnecting

This commit is contained in:
Marco 2024-05-11 22:57:47 +02:00
parent 829a80d62a
commit 58002a1b38
3 changed files with 13 additions and 0 deletions

View File

@ -126,3 +126,9 @@ func JoinPrivateGame(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", "*") c.Header("Access-Control-Allow-Origin", "*")
c.IndentedJSON(http.StatusOK, info) c.IndentedJSON(http.StatusOK, info)
} }
func JoinGame(c *gin.Context) {
gameID := c.Param("id")
log.Println(gameID)
c.JSON(http.StatusOK, gameID)
}

View File

@ -70,3 +70,7 @@ func waitForAndHandlePlayerID(ctx context.Context, conn *gorillaws.Conn) {
lobby.Game.SetWebsocketConnectionFor(ctx, player, conn) lobby.Game.SetWebsocketConnectionFor(ctx, player, conn)
log.Println("player after setting connection: ", player) log.Println("player after setting connection: ", player)
} }
func ConnectWsForGame(c *gin.Context) {
}

View File

@ -28,7 +28,10 @@ func main() {
router.GET("/api/hostPrivate", handler.HostPrivateGameHandler) router.GET("/api/hostPrivate", handler.HostPrivateGameHandler)
router.POST("/api/joinPrivate", handler.JoinPrivateGame) router.POST("/api/joinPrivate", handler.JoinPrivateGame)
router.GET("/api/ws", websocket.RegisterWebSocketConnection) router.GET("/api/ws", websocket.RegisterWebSocketConnection)
router.GET("/api/getLobbyForPassphrase/:phrase", handler.GetLobbyForPassphraseHandler) router.GET("/api/getLobbyForPassphrase/:phrase", handler.GetLobbyForPassphraseHandler)
router.GET("/api/registerWsForGame/:id", websocket.ConnectWsForGame)
router.POST("/api/joinGame/:id", handler.JoinGame)
if debugMode { if debugMode {
log.Println("Starting service WITHOUT TLS") log.Println("Starting service WITHOUT TLS")