Java client BECN implementation (#155)

This commit is contained in:
Jan Chaloupecky
2019-06-01 20:52:13 +01:00
committed by Jason Watkins
parent 90ccec0d07
commit c018d6c3be
14 changed files with 379 additions and 4 deletions

View File

@@ -25,6 +25,8 @@
package gov.nasa.xpc;
import gov.nasa.xpc.discovery.Beacon;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.AutoCloseable;
@@ -136,6 +138,19 @@ public class XPlaneConnect implements AutoCloseable
this(xpHost, xpPort, port, 100);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class from a received discovery Beacon
* @param beacon The beacon received from {@code XPlaneConnectDiscovery}
* @throws SocketException If this instance is unable to bind to the specified port.
*/
public XPlaneConnect(Beacon beacon) throws SocketException {
this.socket = new DatagramSocket(0);
this.xplaneAddr = beacon.getXplaneAddress();
this.xplanePort = beacon.getPluginPort();
this.socket.setSoTimeout(100);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class using the specified ports, hostname, and timeout.
*