vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_Text.C
Go to the documentation of this file.
1#include "vrpn_Text.h"
2
4 vrpn_uint32 level, const struct timeval time)
5{
6 struct timeval now;
7
8 // Replace the time value with the current time if the user passed in the
9 // constant time referring to "now".
10 if ((time.tv_sec == vrpn_TEXT_NOW.tv_sec) &&
11 (time.tv_usec == vrpn_TEXT_NOW.tv_usec)) {
12 vrpn_gettimeofday(&now, NULL);
13 }
14 else {
15 now = time;
16 }
17 // send message, time, type and level
18 return send_text_message(msg, now, type, level);
19}
20
30
32
34{
35
37 vrpn_TEXTCB cp;
38
39 cp.msg_time = p.msg_time;
41 p.buffer);
42
43 // Go down the list of callbacks that have been registered.
44 // Fill in the parameter and call each.
46 return 0;
47}
static int decode_text_message_from_buffer(char *msg, vrpn_TEXT_SEVERITY *severity, vrpn_uint32 *level, const char *buf)
Decodes the body of the text message from a buffer from the connection.
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
vrpn_Connection * d_connection
Connection that this object talks to.
vrpn_int32 d_sender_id
Sender ID registered with the connection.
vrpn_int32 d_text_message_id
ID for text messages.
int send_text_message(const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0)
Sends a NULL-terminated text message from the device d_sender_id.
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
Generic connection class not specific to the transport mechanism.
Allows a user to handle text messages directly, in addition to having the.
Definition vrpn_Text.h:69
vrpn_Text_Receiver(const char *name, vrpn_Connection *c=NULL)
Definition vrpn_Text.C:21
virtual ~vrpn_Text_Receiver(void)
Definition vrpn_Text.C:31
vrpn_Callback_List< vrpn_TEXTCB > d_callback_list
Definition vrpn_Text.h:96
static int VRPN_CALLBACK handle_message(void *userdata, vrpn_HANDLERPARAM p)
Definition vrpn_Text.C:33
int send_message(const char *msg, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0, const struct timeval time=vrpn_TEXT_NOW)
Send a text message.
Definition vrpn_Text.C:3
This structure is what is passed to a vrpn_Connection message callback.
const char * buffer
struct timeval msg_time
Structure passed back to user-level code from a vrpn_Text_Receiver.
Definition vrpn_Text.h:22
char message[vrpn_MAX_TEXT_LEN]
Definition vrpn_Text.h:24
vrpn_TEXT_SEVERITY type
Definition vrpn_Text.h:25
vrpn_uint32 level
Definition vrpn_Text.h:26
struct timeval msg_time
Definition vrpn_Text.h:23
vrpn_TEXT_SEVERITY
Since the sending of text messages has been pulled into the base class (so that every object can send...
#define vrpn_gettimeofday
Definition vrpn_Shared.h:99
const struct timeval vrpn_TEXT_NOW
Definition vrpn_Text.h:19