Make games rejoinable again! #14
@ -58,6 +58,7 @@ func GetLobbyForPassphraseHandler(c *gin.Context) {
|
|||||||
ID: &lobby.Uuid,
|
ID: &lobby.Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.Header("Access-Control-Allow-Origin", "*")
|
||||||
c.IndentedJSON(http.StatusOK, lobbyInfo)
|
c.IndentedJSON(http.StatusOK, lobbyInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +85,7 @@ func JoinPrivateGame(c *gin.Context) {
|
|||||||
_, found = lobby.GetPlayerByUUID(*req.PlayerID)
|
_, found = lobby.GetPlayerByUUID(*req.PlayerID)
|
||||||
}
|
}
|
||||||
if found {
|
if found {
|
||||||
|
c.Header("Access-Control-Allow-Origin", "*")
|
||||||
c.IndentedJSON(
|
c.IndentedJSON(
|
||||||
http.StatusOK,
|
http.StatusOK,
|
||||||
api.PlayerInfo{
|
api.PlayerInfo{
|
||||||
|
@ -220,5 +220,5 @@ func (game *Game) playerDisconnected(p *Player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (game *Game) SetWebsocketConnectionFor(ctx context.Context, p *Player, ws *gorillaws.Conn) {
|
func (game *Game) SetWebsocketConnectionFor(ctx context.Context, p *Player, ws *gorillaws.Conn) {
|
||||||
p.SetWebsocketConnectionAndSendBoardState(ctx, ws, game.board.PGN(), game.board.colorToMove)
|
p.SetWebsocketConnectionAndSendBoardState(ctx, ws, &game.board)
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,10 @@ func (p *Player) SetWebsocketConnection(ctx context.Context, ws *gorillaws.Conn)
|
|||||||
func (p *Player) SetWebsocketConnectionAndSendBoardState(
|
func (p *Player) SetWebsocketConnectionAndSendBoardState(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
ws *gorillaws.Conn,
|
ws *gorillaws.Conn,
|
||||||
boardPosition string,
|
board *Board,
|
||||||
turnColor types.ChessColor,
|
|
||||||
) {
|
) {
|
||||||
p.SetWebsocketConnection(ctx, ws)
|
p.SetWebsocketConnection(ctx, ws)
|
||||||
p.SendBoardState(types.Move{}, boardPosition, turnColor)
|
p.SendBoardState(board.getLastMove(), board.PGN(), board.colorToMove)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) SetColor(color types.ChessColor) {
|
func (p *Player) SetColor(color types.ChessColor) {
|
||||||
|
Loading…
Reference in New Issue
Block a user