1
0

Add new round state

This commit is contained in:
Victor 2014-03-16 19:10:47 +02:00
parent 2f33036837
commit 490c03d7b4
2 changed files with 10 additions and 1 deletions

View File

@ -9,7 +9,8 @@ public interface NetworkListener {
public static final int public static final int
ON_CONNECT = 1, ON_CONNECT = 1,
ON_SEED_RECEIVED = 2, ON_SEED_RECEIVED = 2,
ON_MOVE_RECEIVED = 3; ON_MOVE_RECEIVED = 3,
ON_NEW_ROUND = 4;
public void onStatusChanged(int status, Object data); public void onStatusChanged(int status, Object data);
} }

View File

@ -32,6 +32,7 @@ public class SocketHelper extends Thread {
final int status = dis.readInt(); final int status = dis.readInt();
switch (status) { switch (status) {
case NetworkListener.ON_SEED_RECEIVED: case NetworkListener.ON_SEED_RECEIVED:
case NetworkListener.ON_NEW_ROUND:
listener.onStatusChanged(status, receiveSeed()); listener.onStatusChanged(status, receiveSeed());
break; break;
case NetworkListener.ON_MOVE_RECEIVED: case NetworkListener.ON_MOVE_RECEIVED:
@ -76,6 +77,13 @@ public class SocketHelper extends Thread {
return t; return t;
} }
public void sendNewRoundSeed(long seed) {
try {
dos.writeInt(NetworkListener.ON_NEW_ROUND);
dos.writeLong(seed);
} catch (IOException ex) {}
}
public void close() throws IOException { public void close() throws IOException {
if (dis != null) dis.close(); if (dis != null) dis.close();
if (dos != null) dos.close(); if (dos != null) dos.close();