diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index fad2e67..3f7051b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,10 +7,12 @@
-
-
+
+
+
-
+
+
@@ -61,7 +63,7 @@
"settings.editor.selected.configurable": "discord-project"
}
}
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -92,7 +107,13 @@
+
+
+
+
+
+
@@ -107,6 +128,14 @@
+
+ 1673337087163
+
+
+
+ 1673337087163
+
+
@@ -123,4 +152,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/ch/hevs/synd/sin/UIConstants.java b/src/main/java/ch/hevs/synd/sin/UIConstants.java
index 2764b6c..ffdae04 100644
--- a/src/main/java/ch/hevs/synd/sin/UIConstants.java
+++ b/src/main/java/ch/hevs/synd/sin/UIConstants.java
@@ -7,7 +7,7 @@ package ch.hevs.synd.sin;
*/
public class UIConstants {
/** Defining the default port number to be used. */
- public static final int UI_SERVER_PORT = 1502;
+ public static final int UI_SERVER_PORT = 1515; //1502;
public static final int UI_BUFFER_MAX_SIZE = 256;
/** Messages for DatagramSocket examples */
diff --git a/src/main/java/ch/hevs/synd/sin/stream/Server.java b/src/main/java/ch/hevs/synd/sin/stream/Server.java
new file mode 100644
index 0000000..84c6eee
--- /dev/null
+++ b/src/main/java/ch/hevs/synd/sin/stream/Server.java
@@ -0,0 +1,26 @@
+package ch.hevs.synd.sin.stream;
+
+import ch.hevs.synd.sin.UICommands;
+import ch.hevs.synd.sin.UIConstants;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public class Server {
+ public static void main(String[] args) {
+ try (ServerSocket serverSocket = new ServerSocket(UIConstants.UI_SERVER_PORT)){
+ System.out.println("Server is listening on port " + UIConstants.UI_SERVER_PORT);
+
+ while (true) {
+ Socket socket = serverSocket.accept();
+ System.out.println("New client connected");
+ new ServerThread(socket).start();
+ }
+
+ } catch (IOException ex) {
+ System.out.println("Server exception: " + ex.getMessage());
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/ch/hevs/synd/sin/stream/ServerThread.java b/src/main/java/ch/hevs/synd/sin/stream/ServerThread.java
new file mode 100644
index 0000000..a66cf81
--- /dev/null
+++ b/src/main/java/ch/hevs/synd/sin/stream/ServerThread.java
@@ -0,0 +1,31 @@
+package ch.hevs.synd.sin.stream;
+
+import ch.hevs.synd.sin.network.server.Transaction;
+import ch.hevs.synd.sin.sensor.MeasurementType;
+import ch.hevs.synd.sin.sensor.Sensor;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+
+public class ServerThread extends Thread {
+ private Socket socket;
+ static private Sensor uS = new Sensor(MeasurementType.Voltage,0);
+ static private Sensor iS = new Sensor(MeasurementType.Current, 90);
+ public ServerThread(Socket socket){
+ this.socket = socket;
+ }
+
+ public void run(){
+ try {
+ InputStream is = socket.getInputStream();
+ OutputStream os = socket.getOutputStream();
+ Transaction t = new Transaction(is, os, uS, iS);
+ if(!t.processTransaction()) socket.close();
+ } catch (IOException ex) {
+ System.out.println("Server exception: " + ex.getMessage());
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/ch/hevs/utils/Utility.java b/src/main/java/ch/hevs/utils/Utility.java
index 7e29fee..f550bd0 100644
--- a/src/main/java/ch/hevs/utils/Utility.java
+++ b/src/main/java/ch/hevs/utils/Utility.java
@@ -10,6 +10,9 @@ import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Random;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+
/**
* This class contains some useful Java methods to manipulate data.