Commit 132d0179 authored by fpeterfalvi's avatar fpeterfalvi
Browse files

CommunicationThread bugfix

Closing of the LobbyActivity's CommunicationThread with dummy messages sent by GameActivity.
parent e57691a6
......@@ -43,6 +43,7 @@ public class GameActivity extends AppCompatActivity {
input = new BufferedReader(new InputStreamReader(ServerHolder.getSocket().getInputStream()));
output = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(ServerHolder.getSocket().getOutputStream())),true);
output.println("$$$$");
} catch (IOException e) {
e.printStackTrace();
}
......@@ -65,10 +66,10 @@ public class GameActivity extends AppCompatActivity {
while (!Thread.currentThread().isInterrupted()) {
try {
String read = input.readLine();
if (read != null) {
if (read != null && !read.equals("$$$$")) {
Log.d("GameActivity", "Szervertől kapott üzenet: " + read);
updateConversationHandler.post(new GameActivity.updateUIThread(read));
String params[] = read.split("##");
//String params[] = read.split("##");
}
} catch (IOException e) {
Thread.currentThread().interrupt();
......
......@@ -89,6 +89,7 @@ public class GameActivity extends AppCompatActivity {
inputs.add(new BufferedReader(new InputStreamReader(ClientHolder.get(i).getClientsocket().getInputStream())));
PrintWriter output = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(ClientHolder.get(i).getClientsocket().getOutputStream())), true);
output.println("$$$$");
outputs.add(output);
output.println("GameStarted");
}
......@@ -141,7 +142,7 @@ public class GameActivity extends AppCompatActivity {
while (!Thread.currentThread().isInterrupted()) {
try {
String read = input.readLine();
if (read != null) {
if (read != null && !read.equals("$$$$")) {
Log.d("GameActivity", "Klienstől kapott üzenet: " + read);
updateConversationHandler.post(new GameActivity.updateUIThread(index, read));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment