Skip to content
Snippets Groups Projects
Commit 331a02ae authored by Dennis Eisold's avatar Dennis Eisold
Browse files

DataFunk hinzugefügt und Package umbenannt

parent 552f3a1e
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,7 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<mainClass>Projektarbeit.App</mainClass>
<mainClass>Enigma.App</mainClass>
</configuration>
</plugin>
</plugins>
......
package Projektarbeit;
package Enigma;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
......
package Projektarbeit;
package Enigma;
import java.io.IOException;
import javafx.fxml.FXML;
......
package Projektarbeit;
package Enigma;
import java.io.IOException;
import javafx.fxml.FXML;
......
package Enigma.model;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
public class DataFunk {
public int port = 12345;
public String mcIPStr = "224.0.0.1";
public void receive() throws IOException {
MulticastSocket mcSocket = null;
InetAddress mcIPAddress = null;
mcIPAddress = InetAddress.getByName(mcIPStr);
mcSocket = new MulticastSocket(port);
System.out.println("Multicast Receiver running at:" + mcSocket.getLocalSocketAddress());
mcSocket.joinGroup(mcIPAddress);
DatagramPacket packet = new DatagramPacket(new byte[1024], 1024);
System.out.println("Waiting for a multicast message...");
mcSocket.receive(packet);
String msg = new String(packet.getData(), packet.getOffset(),
packet.getLength());
System.out.println("[Multicast Receiver] Received:" + msg);
mcSocket.leaveGroup(mcIPAddress);
mcSocket.close();
}
public void send(String strSend) throws IOException {
DatagramSocket udpSocket = new DatagramSocket();
InetAddress mcIPAddress = InetAddress.getByName(mcIPStr);
byte[] msg = strSend.getBytes();
DatagramPacket packet = new DatagramPacket(msg, msg.length);
packet.setAddress(mcIPAddress);
packet.setPort(port);
udpSocket.send(packet);
System.out.println("Sent a multicast message.");
System.out.println("Exiting application");
udpSocket.close();
}
}
package Projektarbeit.model;
package Enigma.model;
import java.util.TreeMap;
......
......@@ -2,6 +2,6 @@ module Projektarbeit {
requires javafx.controls;
requires javafx.fxml;
opens Projektarbeit to javafx.fxml;
exports Projektarbeit;
opens Enigma to javafx.fxml;
exports Enigma;
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
<?import javafx.scene.control.Button?>
<?import javafx.geometry.Insets?>
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Projektarbeit.PrimaryController">
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Enigma.PrimaryController">
<children>
<Label text="Primary View" />
<Button fx:id="primaryButton" text="Switch to Secondary View" onAction="#switchToSecondary"/>
......
......@@ -5,7 +5,7 @@
<?import javafx.scene.control.Button?>
<?import javafx.geometry.Insets?>
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Projektarbeit.SecondaryController">
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Enigma.SecondaryController">
<children>
<Label text="Secondary View" />
<Button fx:id="secondaryButton" text="Switch to Primary View" onAction="#switchToPrimary" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment