fix board state when reconnecting and set access headers
This commit is contained in:
parent
682ce8437b
commit
90dca37d44
@ -58,6 +58,7 @@ func GetLobbyForPassphraseHandler(c *gin.Context) {
|
||||
ID: &lobby.Uuid,
|
||||
}
|
||||
|
||||
c.Header("Access-Control-Allow-Origin", "*")
|
||||
c.IndentedJSON(http.StatusOK, lobbyInfo)
|
||||
}
|
||||
|
||||
@ -84,6 +85,7 @@ func JoinPrivateGame(c *gin.Context) {
|
||||
_, found = lobby.GetPlayerByUUID(*req.PlayerID)
|
||||
}
|
||||
if found {
|
||||
c.Header("Access-Control-Allow-Origin", "*")
|
||||
c.IndentedJSON(
|
||||
http.StatusOK,
|
||||
api.PlayerInfo{
|
||||
|
@ -220,5 +220,5 @@ func (game *Game) playerDisconnected(p *Player) {
|
||||
}
|
||||
|
||||
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(
|
||||
ctx context.Context,
|
||||
ws *gorillaws.Conn,
|
||||
boardPosition string,
|
||||
turnColor types.ChessColor,
|
||||
board *Board,
|
||||
) {
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user