|
|
@ -1,27 +1,29 @@ |
|
|
|
package ru.molokoin; |
|
|
|
package ru.molokoin; |
|
|
|
|
|
|
|
|
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
|
|
|
|
import java.util.Queue; |
|
|
|
import java.util.ResourceBundle; |
|
|
|
import java.util.ResourceBundle; |
|
|
|
|
|
|
|
import java.util.concurrent.ArrayBlockingQueue; |
|
|
|
|
|
|
|
|
|
|
|
import javafx.event.Event; |
|
|
|
import javafx.event.Event; |
|
|
|
import javafx.fxml.FXML; |
|
|
|
import javafx.fxml.FXML; |
|
|
|
import javafx.fxml.Initializable; |
|
|
|
import javafx.fxml.Initializable; |
|
|
|
import javafx.scene.control.Button; |
|
|
|
import javafx.scene.control.Button; |
|
|
|
import javafx.scene.control.TextField; |
|
|
|
import javafx.scene.control.TextField; |
|
|
|
import ru.molokoin.example.ExchangeServer; |
|
|
|
import ru.molokoin.ExchangeServer; |
|
|
|
|
|
|
|
|
|
|
|
public class MainFrameController implements Initializable{ |
|
|
|
public class MainFrameController implements Initializable{ |
|
|
|
@FXML |
|
|
|
@FXML |
|
|
|
public Button btn; |
|
|
|
public Button btn; |
|
|
|
@FXML |
|
|
|
@FXML |
|
|
|
public TextField portField; |
|
|
|
public TextField portField; |
|
|
|
public ExchangeServer server; |
|
|
|
public ExchangeServer es; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void initialize(URL location, ResourceBundle resources) { |
|
|
|
public void initialize(URL location, ResourceBundle resources) { |
|
|
|
System.out.println("Инициализация компонентов интерфейса ..."); |
|
|
|
System.out.println("Инициализация компонентов интерфейса ..."); |
|
|
|
try { |
|
|
|
try { |
|
|
|
server = new ExchangeServer(); |
|
|
|
es = new ExchangeServer(); |
|
|
|
} catch (Exception ex) { |
|
|
|
} catch (Exception ex) { |
|
|
|
System.out.println(ex); |
|
|
|
System.out.println(ex); |
|
|
|
} |
|
|
|
} |
|
|
@ -31,13 +33,19 @@ public class MainFrameController implements Initializable{ |
|
|
|
public void buttonClicked(Event e){ |
|
|
|
public void buttonClicked(Event e){ |
|
|
|
if (btn.getText().equals("START")){ |
|
|
|
if (btn.getText().equals("START")){ |
|
|
|
btn.setText("STOP"); |
|
|
|
btn.setText("STOP"); |
|
|
|
server.start(); |
|
|
|
es = new ExchangeServer(); |
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
es.connectionQueue = (Queue<Connection>) new ArrayBlockingQueue(1024); |
|
|
|
|
|
|
|
es.launch = new ServerLauncher(8081, es.connectionQueue); |
|
|
|
|
|
|
|
es.server = new Thread(es.launch); |
|
|
|
|
|
|
|
es.server.setName("ServerLauncherThread"); |
|
|
|
|
|
|
|
es.server.start(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
}else { |
|
|
|
btn.setText("START"); |
|
|
|
btn.setText("START"); |
|
|
|
try { |
|
|
|
try { |
|
|
|
server.finish(); |
|
|
|
//server.finish();
|
|
|
|
} catch (Exception ex) { |
|
|
|
} catch (Exception ex) { |
|
|
|
System.out.println(ex); |
|
|
|
System.out.println(ex); |
|
|
|
} |
|
|
|
} |
|
|
|