@@ -1,6 +1,7 @@
|
||||
package org.orinprojects.desktop;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
@@ -24,21 +25,39 @@ import static org.orinprojects.desktop.Main.keys;
|
||||
public class ChatController {
|
||||
|
||||
|
||||
public TextField messageTextInput;
|
||||
public Button sendMsgBtn;
|
||||
public Text welcomeMessage;
|
||||
public Button connectBtn;
|
||||
public Button disconnectBtn;
|
||||
public TextField serverIpInput;
|
||||
public TextField serverPortInput;
|
||||
public TextField usernameInp;
|
||||
public VBox messagesBox;
|
||||
@FXML
|
||||
TextField messageTextInput;
|
||||
|
||||
|
||||
@FXML
|
||||
Button sendMsgBtn;
|
||||
|
||||
@FXML
|
||||
Text welcomeMessage;
|
||||
|
||||
@FXML
|
||||
Button connectBtn;
|
||||
|
||||
@FXML
|
||||
Button disconnectBtn;
|
||||
|
||||
@FXML
|
||||
TextField serverIpInput;
|
||||
|
||||
@FXML
|
||||
TextField serverPortInput;
|
||||
|
||||
@FXML
|
||||
TextField usernameInp;
|
||||
|
||||
@FXML
|
||||
VBox messagesBox;
|
||||
|
||||
private Socket socket;
|
||||
|
||||
private ClientThread clientThread;
|
||||
|
||||
public void connect(ActionEvent actionEvent) throws IOException {
|
||||
public void connect() throws IOException {
|
||||
if (!serverIpInput.getText().equals("") && !serverPortInput.getText().equals("")) {
|
||||
socket = new Socket(serverIpInput.getText(), Integer.parseInt(serverPortInput.getText()));
|
||||
|
||||
@@ -59,7 +78,7 @@ public class ChatController {
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect(ActionEvent actionEvent) throws IOException {
|
||||
public void disconnect() throws IOException {
|
||||
clientThread.out.close();
|
||||
clientThread.in.close();
|
||||
socket.close();
|
||||
@@ -69,7 +88,7 @@ public class ChatController {
|
||||
sendMsgBtn.setDisable(true);
|
||||
}
|
||||
|
||||
public void sendMessage(ActionEvent actionEvent) throws IllegalBlockSizeException, NoSuchPaddingException, BadPaddingException, NoSuchAlgorithmException, InvalidKeyException {
|
||||
public void sendMessage() throws IllegalBlockSizeException, NoSuchPaddingException, BadPaddingException, NoSuchAlgorithmException, InvalidKeyException {
|
||||
if (!clientThread.aesReceived && !clientThread.rsaReceived)
|
||||
System.out.println("Wait for complete initialisation!");
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ public class ClientThread implements Runnable {
|
||||
|
||||
final PrintWriter out;
|
||||
|
||||
public boolean rsaReceived = false;
|
||||
boolean rsaReceived = false;
|
||||
|
||||
public boolean aesReceived = false;
|
||||
boolean aesReceived = false;
|
||||
|
||||
public Text messageExample;
|
||||
Text messageExample;
|
||||
|
||||
public VBox messagesBox;
|
||||
VBox messagesBox;
|
||||
|
||||
public ClientThread(Socket socket, Text messageExample, VBox messagesBox) throws IOException {
|
||||
this.clientSocket = socket;
|
||||
|
||||
@@ -18,11 +18,11 @@ import java.security.PublicKey;
|
||||
*/
|
||||
public class Main extends Application {
|
||||
|
||||
public static KeyPair keys;
|
||||
static KeyPair keys;
|
||||
|
||||
public static PublicKey serverPublicRSA;
|
||||
static PublicKey serverPublicRSA;
|
||||
|
||||
public static SecretKey aesKey;
|
||||
static SecretKey aesKey;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException, NoSuchAlgorithmException {
|
||||
|
||||
Reference in New Issue
Block a user