From c9a93dd16739fa35b52381206d9d25bcad855116 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 18 Dec 2022 23:06:55 +0100 Subject: [PATCH] Connect to localhost if in debug mode. --- lib/connection/ws_connection.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/connection/ws_connection.dart b/lib/connection/ws_connection.dart index 0e3d701..4fa3f07 100644 --- a/lib/connection/ws_connection.dart +++ b/lib/connection/ws_connection.dart @@ -1,6 +1,7 @@ import 'dart:developer'; import 'dart:io'; +import 'package:flutter/foundation.dart'; import 'package:mchess/chess_bloc/chess_bloc.dart'; import 'package:mchess/chess_bloc/chess_events.dart'; import 'package:mchess/chessapp/chess_utils.dart'; @@ -35,8 +36,12 @@ class ServerConnection { void connect() { if (wasConnected) channel.sink.close(); - channel = - WebSocketChannel.connect(Uri.parse('wss://chess.sw-gross.de:8080')); + if (kDebugMode) { + channel = WebSocketChannel.connect(Uri.parse('ws://localhost:8080')); + } else { + channel = + WebSocketChannel.connect(Uri.parse('wss://chess.sw-gross.de:8080')); + } log(channel.closeCode.toString());