C client API tweaks
- Swaped names of openUDP and aopenUDP. - openUDP is now the "automatic" version, requiring only the X-Plane IP address. - aopenUDP is now the "advanced" version, requiring both the X-Plane port and a client port. - Added support for passing NULL to sendTEXT.
This commit is contained in:
@@ -66,12 +66,12 @@ void printError(char *functionName, char *format, ...)
|
||||
/*****************************************************************************/
|
||||
/**** Low Level UDP functions ****/
|
||||
/*****************************************************************************/
|
||||
XPCSocket aopenUDP(const char *xpIP, unsigned short xpPort)
|
||||
XPCSocket openUDP(const char *xpIP)
|
||||
{
|
||||
return openUDP(xpIP, xpPort, 0);
|
||||
return aopenUDP(xpIP, 49009, 0);
|
||||
}
|
||||
|
||||
XPCSocket openUDP(const char *xpIP, unsigned short xpPort, unsigned short port)
|
||||
XPCSocket aopenUDP(const char *xpIP, unsigned short xpPort, unsigned short port)
|
||||
{
|
||||
XPCSocket sock;
|
||||
|
||||
@@ -432,7 +432,7 @@ int getDREFResponse(XPCSocket sock, float* values[], unsigned char count, int si
|
||||
// Read data. Try 40 times to read, then give up.
|
||||
// TODO: Why not just set the timeout to 40ms?
|
||||
int result;
|
||||
for (int i = 0; i < 40; ++i)
|
||||
for (int i = 0; i < 512; ++i)
|
||||
{
|
||||
result = readUDP(sock, buffer, 65536);
|
||||
if (result > 0)
|
||||
@@ -613,6 +613,10 @@ int sendCTRL(XPCSocket sock, float values[], int size, char ac)
|
||||
/*****************************************************************************/
|
||||
int sendTEXT(XPCSocket sock, char* msg, int x, int y)
|
||||
{
|
||||
if (msg == NULL)
|
||||
{
|
||||
msg = "";
|
||||
}
|
||||
size_t msgLen = strnlen(msg, 255);
|
||||
// Input Validation
|
||||
if (x < -1)
|
||||
|
||||
@@ -67,9 +67,8 @@ typedef enum
|
||||
/// Opens a new connection to XPC on an OS chosen port.
|
||||
///
|
||||
/// \param xpIP A string representing the IP address of the host running X-Plane.
|
||||
/// \param xpPort The port of the X-Plane Connect plugin is listening on. Usually 49009.
|
||||
/// \returns An XPCSocket struct representing the newly created connection.
|
||||
XPCSocket aopenUDP(const char *xpIP, unsigned short xpPort);
|
||||
XPCSocket openUDP(const char *xpIP);
|
||||
|
||||
/// Opens a new connection to XPC on the specified port.
|
||||
///
|
||||
@@ -77,7 +76,7 @@ XPCSocket aopenUDP(const char *xpIP, unsigned short xpPort);
|
||||
/// \param xpPort The port of the X-Plane Connect plugin is listening on. Usually 49009.
|
||||
/// \param port The local port to use when sending and receiving data from XPC.
|
||||
/// \returns An XPCSocket struct representing the newly created connection.
|
||||
XPCSocket openUDP(const char *xpIP, unsigned short xpPort, unsigned short port);
|
||||
XPCSocket aopenUDP(const char *xpIP, unsigned short xpPort, unsigned short port);
|
||||
|
||||
/// Closes the specified connection and releases resources associated with it.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user