From 5ec27cc673221f26479d577e78721e8f0f16fec6 Mon Sep 17 00:00:00 2001 From: WickedJack99 Date: Thu, 28 Dec 2023 21:52:12 +0100 Subject: [PATCH] Controller now starts sender and receiver. --- .../java/controller/src/ControllerThread.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/controller/src/ControllerThread.java b/src/main/java/controller/src/ControllerThread.java index c2b2484..f7f086a 100644 --- a/src/main/java/controller/src/ControllerThread.java +++ b/src/main/java/controller/src/ControllerThread.java @@ -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);