Connect to correct host. Refactor some code.

This commit is contained in:
Marco 2022-12-18 03:21:39 +01:00
parent 2ad028f8a7
commit 23f6a6b14c
3 changed files with 8 additions and 5 deletions

View File

@ -19,7 +19,7 @@ class ChessApp extends StatelessWidget {
child: BlocProvider( child: BlocProvider(
create: (_) => ChessBloc.getInstance(), create: (_) => ChessBloc.getInstance(),
child: MaterialApp( child: MaterialApp(
title: 'mChess', title: 'mChess v0.1.10',
home: Scaffold( home: Scaffold(
body: Container( body: Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(

View File

@ -7,7 +7,7 @@ import 'package:mchess/chess_bloc/chess_bloc.dart';
import '../connection/ws_connection.dart'; import '../connection/ws_connection.dart';
import 'chess_utils.dart'; import 'chess_utils.dart';
int message_index = 0; int messageIndex = 0;
class ChessSquare extends StatelessWidget { class ChessSquare extends StatelessWidget {
final ChessCoordinate coordinate; final ChessCoordinate coordinate;
@ -90,7 +90,7 @@ class ChessSquare extends StatelessWidget {
if (move.endSquare != move.startSquare) { if (move.endSquare != move.startSquare) {
ServerConnection.getInstance().send( ServerConnection.getInstance().send(
'${message_index++} mv ${move.startSquare.toString()} ${move.endSquare.toString()}'); '${messageIndex++} mv ${move.startSquare.toString()} ${move.endSquare.toString()}');
context.read<ChessBloc>().add( context.read<ChessBloc>().add(
PieceMoved( PieceMoved(

View File

@ -14,7 +14,7 @@ class ServerConnection {
static final ServerConnection _instance = ServerConnection._internal(); static final ServerConnection _instance = ServerConnection._internal();
ServerConnection._internal() { ServerConnection._internal() {
log("ServerConnection._interal constructor is called"); log("ServerConnection._internal constructor is called");
connect(); connect();
} }
@ -33,7 +33,10 @@ class ServerConnection {
void connect() { void connect() {
if (wasConnected) channel.sink.close(); 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; wasConnected = true;
broadcast = channel.stream.asBroadcastStream(); broadcast = channel.stream.asBroadcastStream();