From 23f6a6b14cccd5edfb7c2f7994d5e6e68eca7c1e Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 18 Dec 2022 03:21:39 +0100 Subject: [PATCH] Connect to correct host. Refactor some code. --- lib/chessapp/chess_app.dart | 2 +- lib/chessapp/chess_square.dart | 4 ++-- lib/connection/ws_connection.dart | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/chessapp/chess_app.dart b/lib/chessapp/chess_app.dart index 8b81ee8..0edd118 100644 --- a/lib/chessapp/chess_app.dart +++ b/lib/chessapp/chess_app.dart @@ -19,7 +19,7 @@ class ChessApp extends StatelessWidget { child: BlocProvider( create: (_) => ChessBloc.getInstance(), child: MaterialApp( - title: 'mChess', + title: 'mChess v0.1.10', home: Scaffold( body: Container( decoration: const BoxDecoration( diff --git a/lib/chessapp/chess_square.dart b/lib/chessapp/chess_square.dart index f10fb06..9352684 100644 --- a/lib/chessapp/chess_square.dart +++ b/lib/chessapp/chess_square.dart @@ -7,7 +7,7 @@ import 'package:mchess/chess_bloc/chess_bloc.dart'; import '../connection/ws_connection.dart'; import 'chess_utils.dart'; -int message_index = 0; +int messageIndex = 0; class ChessSquare extends StatelessWidget { final ChessCoordinate coordinate; @@ -90,7 +90,7 @@ class ChessSquare extends StatelessWidget { if (move.endSquare != move.startSquare) { ServerConnection.getInstance().send( - '${message_index++} mv ${move.startSquare.toString()} ${move.endSquare.toString()}'); + '${messageIndex++} mv ${move.startSquare.toString()} ${move.endSquare.toString()}'); context.read().add( PieceMoved( diff --git a/lib/connection/ws_connection.dart b/lib/connection/ws_connection.dart index 85e9186..ccab191 100644 --- a/lib/connection/ws_connection.dart +++ b/lib/connection/ws_connection.dart @@ -14,7 +14,7 @@ class ServerConnection { static final ServerConnection _instance = ServerConnection._internal(); ServerConnection._internal() { - log("ServerConnection._interal constructor is called"); + log("ServerConnection._internal constructor is called"); connect(); } @@ -33,7 +33,10 @@ class ServerConnection { void connect() { if (wasConnected) channel.sink.close(); - channel = WebSocketChannel.connect(Uri.parse('ws://localhost:8080')); + channel = + WebSocketChannel.connect(Uri.parse('wss://chess.sw-gross.de:8080')); + log(channel.closeCode.toString()); + wasConnected = true; broadcast = channel.stream.asBroadcastStream();