From 0627a627d845dee12039951eec76c87adf9f882e Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 8 Jun 2023 17:14:50 +0200 Subject: [PATCH] Send new websocket message type for sending a move. --- lib/chess_bloc/chess_bloc.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/chess_bloc/chess_bloc.dart b/lib/chess_bloc/chess_bloc.dart index f4f8fab..0571836 100644 --- a/lib/chess_bloc/chess_bloc.dart +++ b/lib/chess_bloc/chess_bloc.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:mchess/api/move.dart'; +import 'package:mchess/api/websocket_message.dart'; import 'package:mchess/chess_bloc/chess_events.dart'; import 'package:mchess/chess_bloc/chess_position.dart'; import 'package:mchess/connection/ws_connection.dart'; @@ -69,8 +70,10 @@ class ChessBloc extends Bloc { var end = ApiCoordinate(col: event.endSquare.column, row: event.endSquare.row); var move = ApiMove(startSquare: start, endSquare: end); + var message = ApiWebsocketMessage( + type: MessageType.moveMessage, move: move, color: null); - ServerConnection.getInstance().send(jsonEncode(move)); + ServerConnection.getInstance().send(jsonEncode(message)); turnColor = state.newTurnColor == ChessColor.white ? ChessColor.black