Skip to content

Commit

Permalink
Corrects issue #1 (Change server's port)
Browse files Browse the repository at this point in the history
  • Loading branch information
Veleri authored and Veleri committed Feb 28, 2016
1 parent 405a9ce commit c4db8a3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
32 changes: 17 additions & 15 deletions src/main/java/server/controller/ControllerServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @version %I%, %G%
*/
public class ControllerServer extends Observable implements Server{
private final int PORT=1025;
private int PORT;
private ServerSocket socket;
private List<ServerThread> activeUsers;
private ModelActions model;
Expand Down Expand Up @@ -66,13 +66,15 @@ public synchronized void removeActiveUser(ServerThread activeUser){
*/
public ControllerServer(ModelActions model)throws IOException, SAXException{
this.model = model;
this.PORT=Model.getPort();
run();
}
/**
* GUI constructor of servers controller.
* @param serverGUI GUI of servers controller.
*/
public ControllerServer(View serverGUI,ModelActions model){
this.PORT=Model.getPort();
this.serverGUI = serverGUI;
this.model = model;
this.serverGUI.setServer(this);
Expand All @@ -87,23 +89,23 @@ public ControllerServer(View serverGUI,ModelActions model){
public String startGUI(){
if(this.serverGUI!=null){
if (!serverGUI.isServerStart()) {
this.finish=false;
new Thread(new Runnable() {
public void run() {
try {
model.start();
serverGUI.getServer().run();
}
catch (org.xml.sax.SAXException e) {
catchGuiException(e);
}
catch (IOException e){
catchGuiException(e);
this.finish = false;
model.start();
this.PORT = Model.getPort();
new Thread(new Runnable() {
public void run() {
try {
serverGUI.getServer().run();
} catch (org.xml.sax.SAXException e) {
catchGuiException(e);
} catch (IOException e) {
catchGuiException(e);
}
}
}
}).start();
}).start();
serverGUI.setServerStart(true);
return "Stop";

}
if (serverGUI.isServerStart()) {
try {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/server/view/ServerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.awt.event.WindowEvent;
import java.io.IOException;
import server.controller.ControllerServer;
import server.controller.Preference;
import server.controller.Server;
import server.model.ModelActions;

Expand All @@ -25,6 +26,7 @@ public class ServerView extends JFrame implements View{
private Server server;
private JButton gracefulReload;
private boolean clickStart;
private static final String RELOAD = Preference.Successfully+"! Changes will take effect after server is reloaded.";
/**
* Constructor of server GUI.
*/
Expand Down Expand Up @@ -154,7 +156,7 @@ public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(ActionEvent e) {
gracefulReload();
display("Graceful Reload is successful.");
display(RELOAD);
}
});
return buttonPanel;
Expand Down

0 comments on commit c4db8a3

Please sign in to comment.