Browse Source

merge Kommunikation Version 1.3 UDP Socket

Kommunikation
Miguel Siebenhaar 1 year ago
parent
commit
0782bbdd04

+ 0
- 6
app/src/main/java/com/example/ueberwachungssystem/WifiCommunication.java View File

try { try {
do { do {
byte[] receiveData = new byte[512]; byte[] receiveData = new byte[512];
InetAddress fromAdress;
int fromPort;
DatagramPacket rxPacket = new DatagramPacket(receiveData, receiveData.length); DatagramPacket rxPacket = new DatagramPacket(receiveData, receiveData.length);
socket.receive(rxPacket); socket.receive(rxPacket);
fromAdress = rxPacket.getAddress();
fromPort = rxPacket.getPort();
rxString = new String(rxPacket.getData()); rxString = new String(rxPacket.getData());
if(!previousRxString.equals(rxString)) { if(!previousRxString.equals(rxString)) {
rxStringBuffer.append(rxString).append("\n"); rxStringBuffer.append(rxString).append("\n");
mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer)); mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer));
previousRxString = rxString; previousRxString = rxString;
} }


} while (running); } while (running);
} }
catch (IOException e) { catch (IOException e) {

Loading…
Cancel
Save