mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-20 16:59:53 +00:00
refactoring....
This commit is contained in:
@@ -74,7 +74,7 @@ public class UDPHome implements Home {
|
||||
sendData = theUrlBody.getBytes();
|
||||
}
|
||||
try {
|
||||
theUDPDatagramSender.sendUDPResponse(new String(sendData), IPAddress,
|
||||
theUDPDatagramSender.sendUDPResponse(sendData, IPAddress,
|
||||
Integer.parseInt(port));
|
||||
} catch (NumberFormatException e) {
|
||||
// noop
|
||||
|
||||
@@ -209,7 +209,7 @@ public class UpnpListener {
|
||||
}
|
||||
else
|
||||
log.debug("sendUpnpResponse discovery responseTemplate1 is <<<" + discoveryResponse + ">>>");
|
||||
theUDPDatagramSender.sendUDPResponse(discoveryResponse, requester, sourcePort);
|
||||
theUDPDatagramSender.sendUDPResponse(discoveryResponse.getBytes(), requester, sourcePort);
|
||||
|
||||
discoveryResponse = String.format(responseTemplate2, Configuration.UPNP_MULTICAST_ADDRESS, Configuration.UPNP_DISCOVERY_PORT, responseAddress, httpServerPort, bridgeId, bridgeSNUUID, bridgeSNUUID);
|
||||
if(traceupnp) {
|
||||
@@ -217,7 +217,7 @@ public class UpnpListener {
|
||||
}
|
||||
else
|
||||
log.debug("sendUpnpResponse discovery responseTemplate2 is <<<" + discoveryResponse + ">>>");
|
||||
theUDPDatagramSender.sendUDPResponse(discoveryResponse, requester, sourcePort);
|
||||
theUDPDatagramSender.sendUDPResponse(discoveryResponse.getBytes(), requester, sourcePort);
|
||||
|
||||
discoveryResponse = String.format(responseTemplate3, Configuration.UPNP_MULTICAST_ADDRESS, Configuration.UPNP_DISCOVERY_PORT, responseAddress, httpServerPort, bridgeId, bridgeSNUUID);
|
||||
if(traceupnp) {
|
||||
@@ -225,6 +225,6 @@ public class UpnpListener {
|
||||
}
|
||||
else
|
||||
log.debug("sendUpnpResponse discovery responseTemplate3 is <<<" + discoveryResponse + ">>>");
|
||||
theUDPDatagramSender.sendUDPResponse(discoveryResponse, requester, sourcePort);
|
||||
theUDPDatagramSender.sendUDPResponse(discoveryResponse.getBytes(), requester, sourcePort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,11 +62,11 @@ public class UDPDatagramSender {
|
||||
responseSocket.close();
|
||||
}
|
||||
|
||||
public void sendUDPResponse(String udpResponse, InetAddress requester, int sourcePort) throws IOException {
|
||||
log.debug("Sending response string: <<<" + udpResponse + ">>>");
|
||||
public void sendUDPResponse(byte[] udpMessage, InetAddress requester, int sourcePort) throws IOException {
|
||||
log.debug("Sending response string: <<<" + new String(udpMessage) + ">>>");
|
||||
if(responseSocket == null)
|
||||
throw new IOException("Socket not initialized");
|
||||
DatagramPacket response = new DatagramPacket(udpResponse.getBytes(), udpResponse.length(), requester, sourcePort);
|
||||
DatagramPacket response = new DatagramPacket(udpMessage, udpMessage.length, requester, sourcePort);
|
||||
responseSocket.send(response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user