File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -461,6 +461,15 @@ public Message getUIMessage() {
461461 return mUIMessage ;
462462 }
463463
464+ public Message getStatusMessage () {
465+ Object [] args = new Object [] {new Object ()};
466+
467+
468+
469+ Message status = new Message (Message .NAME_STATUS , args );
470+ return status ;
471+ }
472+
464473 @ Override
465474 public Message [] getClientMessages () {
466475 return mClientMessages .toArray (new Message [mClientMessages .size ()]);
Original file line number Diff line number Diff line change @@ -212,11 +212,16 @@ public void run() {
212212 mGameLogic .simulateEvents (terminalEvents , environmentEvents , clientEvents );
213213 mGameLogic .generateOutputs ();
214214 if (mGameLogic .isGameFinished ()) {
215+ Message shutdown = new Message (Message .NAME_SHUTDOWN , new Object [] {});
216+ for (int i = 0 ; i < mClientsInfo .length ; i ++) {
217+ mClientNetwork .queue (i , shutdown );
218+ }
215219 mLoop .shutdown ();
216220 mOutputController .shutdown ();
217221 }
218222
219223 mOutputController .putMessage (mGameLogic .getUIMessage ());
224+ mOutputController .putMessage (mGameLogic .getStatusMessage ());
220225
221226 Message [] output = mGameLogic .getClientMessages ();
222227 for (int i = 0 ; i < output .length ; ++i ) {
@@ -243,7 +248,7 @@ public void run() {
243248 clientEvents [i ] = mClientNetwork .getReceivedEvent (i );
244249 }
245250 }
246- //FIXME: Put a blocking queue for terminal
251+
247252 BlockingQueue <Event > terminalEventsQueue = new LinkedBlockingQueue <>();
248253
249254 synchronized (terminalEventsQueue ) {
Original file line number Diff line number Diff line change 1717 */
1818public interface GameLogic {
1919
20- //TODO: Saeed Rajab, change these... common baby...
2120 /**
2221 * This method must send initial and necessary values to UI and clients.
2322 * @return A hashmap that has <code>Token</code> as <strong>key</strong> and a <code>Message</code> as <strong>value</strong>.
@@ -62,6 +61,8 @@ public interface GameLogic {
6261
6362 public Message getUIMessage ();
6463
64+ public Message getStatusMessage ();
65+
6566 public Message [] getClientMessages ();
6667
6768 /**
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ public class Message {
77
88 public static final String NAME_TURN = "turn" ;
99 public static final String NAME_INIT = "init" ;
10+ public static final String NAME_STATUS = "status" ;
11+ public static final String NAME_SHUTDOWN = "shutdown" ;
1012
1113 public String name ;
1214 public Object [] args ;
You can’t perform that action at this time.
0 commit comments