Controller now starts sender and receiver.

This commit is contained in:
WickedJack99
2023-12-28 21:52:12 +01:00
parent 72eafc8c3c
commit 5ec27cc673

View File

@@ -6,7 +6,7 @@ package controller.src;
import connect.src.Client;
import connect.src.TLSClient;
import controller.src.DataProcessing.DataProcessorThread;
import controller.src.Validate.Validate;
import data.src.ControllerToConnectionClient.ConnectToServer;
@@ -25,6 +25,7 @@ import logger.src.MessageLogger;
import model.src.ModelRepresentation;
import model.src.ConnectionModel.ConnectionStatus;
import queues.src.ControllerToViewQueue;
import queues.src.SendingQueue;
import queues.src.ViewToControllerQueue;
public class ControllerThread extends Thread implements Controller {
@@ -55,7 +56,7 @@ public class ControllerThread extends Thread implements Controller {
case ViewEvent.ConnectToServerButtonWasPressed: {
handleConnectToServerButtonWasPressed(viewToControllerData);
}break;
default: {
}break;
@@ -64,6 +65,13 @@ public class ControllerThread extends Thread implements Controller {
MessageLogger.printMessage(className, "Exit controller thread.");
}
/**
* Is called if controller received event from view, which indicates,
* that the connect to server button was pressed. The function takes
* a parameter of type ViewToControllerData which contains the information
* necessary to establish a connection to a server.
* @param viewToControllerData
*/
private void handleConnectToServerButtonWasPressed(ViewToControllerData viewToControllerData) {
this.model.getConnectionModel().setConnectionStatus(ConnectionStatus.Pending);
@@ -87,6 +95,13 @@ public class ControllerThread extends Thread implements Controller {
this.client = new TLSClient();
if (this.client.createConnection(connectToServerData) == true) {
DataProcessorThread.getInstance().start();
this.client.startReceiver();
this.client.startSender();
//SendingQueue.getInstance().add("getSysInf");
SendingQueue.getInstance().add("getCon");
//SendingQueue.getInstance().add("getNFTConf");
this.model.getConnectionModel().setConnectionStatus(ConnectionStatus.Connected);
ControllerToViewData controllerToViewData = new ConnectToServerSuccessful();
ControllerToViewQueue.getInstance().add(controllerToViewData);