NetworkUtilities 1.4.2
A small compiled library for C network utility functions.
Loading...
Searching...
No Matches
Messaging

Functions related to formatting messages for transmission or for handling their receipt. More...

Functions

int sendMessage (SOCKET udpSocket, struct sockaddr_in serverAddr, char *message)
 Sends cursor position over UDP socket.
 
int sendCursorPosition (SOCKET udpSocket, struct sockaddr_in serverAddr, uint16_t x, uint16_t y, uint8_t renderFlag, const char *tag)
 Sends cursor position over UDP socket.
 
int sendRenderParameters (SOCKET udpSocket, struct sockaddr_in serverAddr, uint8_t radius_cursor, uint8_t radius_targets, uint8_t line_width, const char *tag)
 Sends rendering parameters over UDP socket.
 
int sendTargetUpdate (SOCKET udpSocket, struct sockaddr_in serverAddr, uint16_t x1, uint16_t y1, uint8_t render1, uint16_t x2, uint16_t y2, uint8_t render2, const char *tag)
 Sends target update information over UDP socket.
 
void receiveCursorMessage (SOCKET udpSocket, RenderedCircleData *cursor)
 Receives cursor message over UDP socket.
 
void receiveTargetMessage (SOCKET udpSocket, RenderedCircleData **targets)
 Receives target message over UDP socket.
 

Detailed Description

Functions related to formatting messages for transmission or for handling their receipt.

Function Documentation

◆ receiveCursorMessage()

void receiveCursorMessage ( SOCKET udpSocket,
RenderedCircleData * cursor )

Receives cursor message over UDP socket.

This function receives cursor message data over the specified UDP socket. It receives the message, parses it assuming it's in the format "x,y", and updates the cursor position based on the received data.

Parameters
udpSocketThe UDP socket to receive the cursor message on.
cursorPointer to the struct where cursor data will be updated.

◆ receiveTargetMessage()

void receiveTargetMessage ( SOCKET udpSocket,
RenderedCircleData ** targets )

Receives target message over UDP socket.

This function receives target message data over the specified UDP socket. It receives the message, parses it assuming it's in the format "x,y,targetIndex,renderFlag", and updates the corresponding target position and render flag based on the received data.

Parameters
udpSocketThe UDP socket to receive the target message on.
targetsArray of pointers to RenderedCircleData representing targets.

◆ sendCursorPosition()

int sendCursorPosition ( SOCKET udpSocket,
struct sockaddr_in serverAddr,
uint16_t x,
uint16_t y,
uint8_t renderFlag,
const char * tag )

Sends cursor position over UDP socket.

This function sends cursor position data over the specified UDP socket.

Parameters
udpSocketThe UDP socket to send the cursor position over.
serverAddrThe server address structure for UDP remote socket.
xThe x-coordinate of the cursor position (pixels).
yThe y-coordinate of the cursor position (pixels).
renderFlagFlag indicating whether or not to render the cursor.
tag(Optional) either NULL or some identifier string that forces it to print debug statement of what the sent message is.
Returns
EXIT_SUCCESS on success, EXIT_FAILURE on failure.

◆ sendMessage()

int sendMessage ( SOCKET udpSocket,
struct sockaddr_in serverAddr,
char * message )

Sends cursor position over UDP socket.

This function sends cursor position data over the specified UDP socket.

Parameters
udpSocketThe UDP socket to send the cursor position over.
serverAddrThe server address structure for UDP remote socket.
messageThe message to send to the server.
Returns
EXIT_SUCCESS on success, EXIT_FAILURE on failure.

◆ sendRenderParameters()

int sendRenderParameters ( SOCKET udpSocket,
struct sockaddr_in serverAddr,
uint8_t radius_cursor,
uint8_t radius_targets,
uint8_t line_width,
const char * tag )

Sends rendering parameters over UDP socket.

This function sends size parameters for rendering circles over the specified UDP socket.

Parameters
udpSocketThe UDP socket to send the cursor position over.
serverAddrThe server address structure for UDP remote socket.
radius_cursorRadius of cursor circle (pixels).
radius_targetsRadius of target circles (pixels).
line_widthWidth of lines (pixels).
tag(Optional) either NULL or some identifier string that forces it to print debug statement of what the sent message is.
Returns
EXIT_SUCCESS on success, EXIT_FAILURE on failure.

◆ sendTargetUpdate()

int sendTargetUpdate ( SOCKET udpSocket,
struct sockaddr_in serverAddr,
uint16_t x1,
uint16_t y1,
uint8_t render1,
uint16_t x2,
uint16_t y2,
uint8_t render2,
const char * tag )

Sends target update information over UDP socket.

This function sends target update information over the specified UDP socket.

Parameters
udpSocketThe UDP socket to send the target update over.
serverAddrThe server address structure for UDP remote socket.
x1The x-coordinate of T1 (pixels).
y1The y-coordinate of T1 (pixels).
render1The render flag indicating whether to render T1.
x2The x-coordinate of T2 (pixels).
y2The y-coordinate of T2 (pixels).
render2The render flag indicating whether to render T2.
tag(Optional) either NULL or some identifier string that forces it to print debug statement of what the sent message is.
Returns
EXIT_SUCCESS on success, EXIT_FAILURE on failure.