Tilde Friends
Packet Stream

Typedefs

typedef struct uv_pipe_s uv_pipe_t
 
typedef struct _tf_packetstream_t tf_packetstream_t
 
typedef void() tf_packetstream_onreceive_t(int packet_type, const char *begin, size_t length, void *user_data)
 
typedef void() tf_packetstream_on_close_t(void *user_data)
 

Functions

tf_packetstream_ttf_packetstream_create ()
 
void tf_packetstream_destroy (tf_packetstream_t *stream)
 
void tf_packetstream_start (tf_packetstream_t *stream)
 
void tf_packetstream_send (tf_packetstream_t *stream, int packet_type, const char *begin, size_t length)
 
void tf_packetstream_set_on_receive (tf_packetstream_t *stream, tf_packetstream_onreceive_t *callback, void *user_data)
 
void tf_packetstream_set_on_close (tf_packetstream_t *stream, tf_packetstream_on_close_t *callback, void *user_data)
 
void tf_packetstream_close (tf_packetstream_t *stream)
 
uv_pipe_ttf_packetstream_get_pipe (tf_packetstream_t *stream)
 

Detailed Description

Primitive helper for sending packets of known size across a pipe.

Typedef Documentation

◆ tf_packetstream_on_close_t

typedef void() tf_packetstream_on_close_t(void *user_data)

A function called when a packetstream reads EOF.

Parameters
user_dataUser data.

◆ tf_packetstream_onreceive_t

typedef void() tf_packetstream_onreceive_t(int packet_type, const char *begin, size_t length, void *user_data)

A function called when a packet is received.

Parameters
packet_typeThe type of the packet as specified by the sender.
beginThe beginning of the data.
lengthThe length of the data.
user_dataUser data.

◆ tf_packetstream_t

typedef struct _tf_packetstream_t tf_packetstream_t

A packet stream instance.

◆ uv_pipe_t

typedef struct uv_pipe_s uv_pipe_t

A handle to a UNIX-style pipe.

Function Documentation

◆ tf_packetstream_close()

void tf_packetstream_close ( tf_packetstream_t stream)

Close a packet stream.

Parameters
streamThe packet stream.

◆ tf_packetstream_create()

tf_packetstream_t * tf_packetstream_create ( )

Create a packet stream.

Returns
The packet stream.

◆ tf_packetstream_destroy()

void tf_packetstream_destroy ( tf_packetstream_t stream)

Destroy a packet stream.

Parameters
streamThe packet stream.

◆ tf_packetstream_get_pipe()

uv_pipe_t * tf_packetstream_get_pipe ( tf_packetstream_t stream)

Get the internal pipe object from a packet stream.

Parameters
streamThe packet stream.
Returns
The pipe.

◆ tf_packetstream_send()

void tf_packetstream_send ( tf_packetstream_t stream,
int  packet_type,
const char *  begin,
size_t  length 
)

Send a discrete packet over a packet stream.

Parameters
streamThe packet stream.
packet_typeThe type of the packet.
beginThe start of the packet data.
lengthThe length of the packet data.

◆ tf_packetstream_set_on_close()

void tf_packetstream_set_on_close ( tf_packetstream_t stream,
tf_packetstream_on_close_t callback,
void *  user_data 
)

Register a callback for when a stream reads EOF.

Parameters
streamThe packet stream.
callbackThe callback.
user_dataUser data to pass to the callback.

◆ tf_packetstream_set_on_receive()

void tf_packetstream_set_on_receive ( tf_packetstream_t stream,
tf_packetstream_onreceive_t callback,
void *  user_data 
)

Register the callback to be called when a message is received.

Parameters
streamThe packet stream.
callbackThe callback function.
user_dataUser data to pass to the callback.

◆ tf_packetstream_start()

void tf_packetstream_start ( tf_packetstream_t stream)

Start a packet stream receiving.

Parameters
streamThe packet stream.