From 31faabcf9468591f034f25cda42e9c60eed83b49 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 18 Dec 2022 15:54:19 +0100 Subject: [PATCH] Connect to localhost when I am on my dev environment. --- lib/connection/ws_connection.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/connection/ws_connection.dart b/lib/connection/ws_connection.dart index ccab191..4ea66dd 100644 --- a/lib/connection/ws_connection.dart +++ b/lib/connection/ws_connection.dart @@ -1,4 +1,5 @@ import 'dart:developer'; +import 'dart:io'; import 'package:mchess/chess_bloc/chess_bloc.dart'; import 'package:mchess/chess_bloc/chess_events.dart'; @@ -33,8 +34,13 @@ class ServerConnection { void connect() { if (wasConnected) channel.sink.close(); - channel = - WebSocketChannel.connect(Uri.parse('wss://chess.sw-gross.de:8080')); + if (Platform.localHostname == 'mbook') { + // My test environment + channel = WebSocketChannel.connect(Uri.parse('ws://localhost:8080')); + } else { + channel = + WebSocketChannel.connect(Uri.parse('wss://chess.sw-gross.de:8080')); + } log(channel.closeCode.toString()); wasConnected = true;