Send new websocket message type for sending a move.
This commit is contained in:
parent
6e5d84364d
commit
0627a627d8
@ -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<ChessEvent, ChessBoardState> {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user