Updated 'ServerState' class.
Updated the 'ServerState' class by filling the 'received(LeaveGameMessage msg, int from)' in it.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package pp.mdga.server.automaton;
|
package pp.mdga.server.automaton;
|
||||||
|
|
||||||
import pp.mdga.message.client.*;
|
import pp.mdga.message.client.*;
|
||||||
|
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
|
||||||
|
import pp.mdga.message.server.ShutdownMessage;
|
||||||
import pp.mdga.server.ServerGameLogic;
|
import pp.mdga.server.ServerGameLogic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +77,15 @@ public void received(JoinedLobbyMessage msg, int from) {}
|
|||||||
* @param msg as the message which was sent by the player as a LeaveGameMessage object.
|
* @param msg as the message which was sent by the player as a LeaveGameMessage object.
|
||||||
* @param from as the client id of the player as an Integer.
|
* @param from as the client id of the player as an Integer.
|
||||||
*/
|
*/
|
||||||
public void received(LeaveGameMessage msg, int from) {}
|
public void received(LeaveGameMessage msg, int from) {
|
||||||
|
if (from == this.logic.getGame().getHost()) {
|
||||||
|
this.logic.getServerSender().broadcast(new ShutdownMessage());
|
||||||
|
this.logic.getServerSender().shutdown();
|
||||||
|
}
|
||||||
|
this.logic.getGame().removePlayer(from);
|
||||||
|
this.logic.getServerSender().broadcast(new LobbyPlayerLeaveMessage(from));
|
||||||
|
this.logic.getServerSender().disconnectClient(from);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be called whenever the server received a LobbyReadyMessage message.
|
* This method will be called whenever the server received a LobbyReadyMessage message.
|
||||||
|
|||||||
Reference in New Issue
Block a user