fixed not working single mode, added read port from textline when client host server
This commit is contained in:
@@ -32,7 +32,7 @@ robot.targets=2, 0,\
|
||||
2, 6
|
||||
#
|
||||
# Delay in milliseconds between each shot fired by the RobotClient.
|
||||
robot.delay=500
|
||||
robot.delay=4000
|
||||
#
|
||||
# The dimensions of the game map used in single mode.
|
||||
# 'map.width' defines the number of columns, and 'map.height' defines the number of rows.
|
||||
|
||||
@@ -84,9 +84,7 @@ public void initialize(AppStateManager stateManager, Application app) {
|
||||
* Plays the shell flying sound effect.
|
||||
*/
|
||||
public void shellFly() {
|
||||
System.out.println("shellFly");
|
||||
if (isEnabled() && shellFlyingSound != null) {
|
||||
System.out.println("play shell");
|
||||
shellFlyingSound.playInstance();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ private Object initNetwork() {
|
||||
private Object initServer() {
|
||||
try {
|
||||
server = new BattleshipServerClient();
|
||||
server.run();
|
||||
server.run(Integer.parseInt(port.getText()));
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -85,8 +85,8 @@ public boolean isReady() {
|
||||
/**
|
||||
* Starts the server and continuously processes incoming messages.
|
||||
*/
|
||||
public void run() {
|
||||
startServer();
|
||||
public void run(int port) {
|
||||
startServer(port);
|
||||
while (true)
|
||||
processNextMessage();
|
||||
}
|
||||
@@ -94,10 +94,10 @@ public void run() {
|
||||
/**
|
||||
* Starts the server by creating a network server on the specified port.
|
||||
*/
|
||||
private void startServer() {
|
||||
private void startServer(int port) {
|
||||
try {
|
||||
LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS
|
||||
myServer = Network.createServer(config.getPort());
|
||||
myServer = Network.createServer(port);
|
||||
initializeSerializables();
|
||||
myServer.start();
|
||||
registerListeners();
|
||||
|
||||
Reference in New Issue
Block a user