vrpn 07.35
Virtual Reality Peripheral Network
|
Encapsulation of the data and methods for a single generic connection to take care of one part of many clients talking to a single server. More...
#include <vrpn_Connection.h>
Public Member Functions | |
vrpn_Endpoint (vrpn_TypeDispatcher *dispatcher, vrpn_int32 *connectedEndpointCounter) | |
virtual | ~vrpn_Endpoint (void) |
virtual int | pack_message (vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service)=0 |
Pack a message that will be sent the next time mainloop() is called. Turn off the RELIABLE flag if you want low-latency (UDP) send. | |
virtual int | send_pending_reports (void)=0 |
send pending report, clear the buffer. This function was protected, now is public, so we can use it to send out intermediate results without calling mainloop | |
int | pack_log_description (void) |
Packs the log description set by setup_new_connection(). | |
virtual int | setup_new_connection (void)=0 |
Sends the magic cookie and other information to its peer. It is called by both the client and server setup routines. | |
virtual void | poll_for_cookie (const timeval *timeout=NULL)=0 |
virtual int | finish_new_connection_setup (void)=0 |
virtual void | drop_connection (void)=0 |
Should only be called by vrpn_Connection::drop_connection(), since there's more housecleaning to do at that level. I suppose that argues against separating this function out. | |
virtual void | clearBuffers (void)=0 |
Empties out the TCP and UDP send buffers. Needed by vrpn_FileConnection to get at {udp,tcp}NumOut. | |
int | pack_sender_description (vrpn_int32 which) |
Packs a sender description over our socket. | |
int | pack_type_description (vrpn_int32 which) |
Packs a type description. | |
Accessors | |
int | local_type_id (vrpn_int32 remote_type) const |
Returns the local mapping for the remote type (-1 if none). | |
int | local_sender_id (vrpn_int32 remote_sender) const |
Returns the local mapping for the remote sender (-1 if none). | |
virtual vrpn_bool | doing_okay (void) const =0 |
Manipulators | |
void | init (void) |
virtual int | mainloop (timeval *timeout)=0 |
void | clear_other_senders_and_types (void) |
Clear out the remote mapping list. This is done when a connection is dropped and we want to try and re-establish it. | |
int | newLocalSender (const char *name, vrpn_int32 which) |
A new local sender or type has been established; set the local type for it if the other side has declared it. Return 1 if the other side has one, 0 if not. | |
int | newLocalType (const char *name, vrpn_int32 which) |
int | newRemoteType (cName type_name, vrpn_int32 remote_id, vrpn_int32 local_id) |
Adds a new remote type/sender and returns its index. Returns -1 on error. | |
int | newRemoteSender (cName sender_name, vrpn_int32 remote_id, vrpn_int32 local_id) |
Routines to inform the endpoint of the connection of | |
which it is a part. | |
void | setConnection (vrpn_Connection *conn) |
vrpn_Connection * | getConnection () |
Static Public Member Functions | |
Routines that handle system messages | |
Visible so that vrpn_Connection can pass them to the Dispatcher | |
static int VRPN_CALLBACK | handle_sender_message (void *userdata, vrpn_HANDLERPARAM p) |
static int VRPN_CALLBACK | handle_type_message (void *userdata, vrpn_HANDLERPARAM p) |
Public Attributes | |
int | status |
long | d_remoteLogMode |
Mode to put the remote logging in. | |
char * | d_remoteInLogName |
Name of the remote log file. | |
char * | d_remoteOutLogName |
Name of the remote log file. | |
char | rhostname [150] |
Protected Member Functions | |
virtual int | dispatch (vrpn_int32 type, vrpn_int32 sender, timeval time, vrpn_uint32 payload_len, char *bufptr) |
int | tryToMarshall (char *outbuf, vrpn_int32 &buflen, vrpn_int32 &numOut, vrpn_uint32 len, timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 classOfService) |
Calls marshall_message(); if that fails, calls send_pending_reports() and then marshalls again. Returns the number of characters successfully marshalled. | |
int | marshall_message (char *outbuf, vrpn_uint32 outbuf_size, vrpn_uint32 initial_out, vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 sequenceNumber) |
Marshal the message into the buffer if it will fit. | |
Protected Attributes | |
vrpn_TranslationTable * | d_senders |
vrpn_TranslationTable * | d_types |
vrpn_TypeDispatcher * | d_dispatcher |
vrpn_int32 * | d_connectionCounter |
vrpn_Connection * | d_parent |
Logging | |
TCH 19 April 00; changed into two logs 16 Feb 01 | |
vrpn_Log * | d_inLog |
vrpn_Log * | d_outLog |
void | setLogNames (const char *inName, const char *outName) |
int | openLogs (void) |
Encapsulation of the data and methods for a single generic connection to take care of one part of many clients talking to a single server.
This will only be used from within the vrpn_Connection class; it should not be instantiated by users or devices. Should not be visible!
Definition at line 253 of file vrpn_Connection.h.
vrpn_Endpoint::vrpn_Endpoint | ( | vrpn_TypeDispatcher * | dispatcher, |
vrpn_int32 * | connectedEndpointCounter ) |
Definition at line 2762 of file vrpn_Connection.C.
References init().
|
virtual |
Definition at line 2809 of file vrpn_Connection.C.
References d_inLog, d_outLog, d_remoteInLogName, d_remoteOutLogName, d_senders, and d_types.
void vrpn_Endpoint::clear_other_senders_and_types | ( | void | ) |
Clear out the remote mapping list. This is done when a connection is dropped and we want to try and re-establish it.
Definition at line 3195 of file vrpn_Connection.C.
References d_senders, and d_types.
Referenced by vrpn_Endpoint_IP::drop_connection(), and vrpn_Connection::handle_disconnect_message().
|
pure virtual |
Empties out the TCP and UDP send buffers. Needed by vrpn_FileConnection to get at {udp,tcp}NumOut.
Implemented in vrpn_Endpoint_IP.
|
protectedvirtual |
Definition at line 4312 of file vrpn_Connection.C.
References d_dispatcher, local_sender_id(), and local_type_id().
Referenced by vrpn_Endpoint_IP::getOneTCPMessage(), and vrpn_Endpoint_IP::getOneUDPMessage().
|
pure virtual |
Implemented in vrpn_Endpoint_IP.
|
pure virtual |
Should only be called by vrpn_Connection::drop_connection(), since there's more housecleaning to do at that level. I suppose that argues against separating this function out.
Implemented in vrpn_Endpoint_IP.
Referenced by vrpn_Connection_IP::drop_connection().
|
pure virtual |
Implemented in vrpn_Endpoint_IP.
|
inline |
Definition at line 378 of file vrpn_Connection.h.
|
static |
Definition at line 4535 of file vrpn_Connection.C.
References vrpn_HANDLERPARAM::buffer, d_dispatcher, d_parent, newRemoteSender(), vrpn_HANDLERPARAM::payload_len, vrpn_Connection::register_sender(), and vrpn_HANDLERPARAM::sender.
|
static |
Definition at line 4463 of file vrpn_Connection.C.
References vrpn_HANDLERPARAM::buffer, d_dispatcher, d_parent, newRemoteType(), vrpn_HANDLERPARAM::payload_len, vrpn_Connection::register_message_type(), and vrpn_HANDLERPARAM::sender.
void vrpn_Endpoint::init | ( | void | ) |
Definition at line 2951 of file vrpn_Connection.C.
References BROKEN, d_inLog, d_outLog, d_senders, d_types, status, vrpn_Log, and vrpn_TranslationTable.
Referenced by vrpn_Endpoint().
int vrpn_Endpoint::local_sender_id | ( | vrpn_int32 | remote_sender | ) | const |
Returns the local mapping for the remote sender (-1 if none).
Definition at line 2937 of file vrpn_Connection.C.
References d_senders.
Referenced by dispatch(), and vrpn_File_Connection::playone_to_filetime().
int vrpn_Endpoint::local_type_id | ( | vrpn_int32 | remote_type | ) | const |
Returns the local mapping for the remote type (-1 if none).
Definition at line 2932 of file vrpn_Connection.C.
References d_types.
Referenced by dispatch(), vrpn_Endpoint_IP::getOneUDPMessage(), and vrpn_File_Connection::playone_to_filetime().
|
pure virtual |
Implemented in vrpn_Endpoint_IP.
|
protected |
Marshal the message into the buffer if it will fit.
Return the number of characters sent (either 0 or the number requested). This function should not be called directly; rather, call tryToMarshall, which will flush the outgoing buffer if the marshalling attempt fails.
Definition at line 4378 of file vrpn_Connection.C.
References vrpn_ALIGN.
Referenced by tryToMarshall().
int vrpn_Endpoint::newLocalSender | ( | const char * | name, |
vrpn_int32 | which ) |
A new local sender or type has been established; set the local type for it if the other side has declared it. Return 1 if the other side has one, 0 if not.
Definition at line 3205 of file vrpn_Connection.C.
References d_senders.
int vrpn_Endpoint::newLocalType | ( | const char * | name, |
vrpn_int32 | which ) |
Definition at line 3214 of file vrpn_Connection.C.
References d_types.
int vrpn_Endpoint::newRemoteSender | ( | cName | sender_name, |
vrpn_int32 | remote_id, | ||
vrpn_int32 | local_id ) |
Definition at line 3227 of file vrpn_Connection.C.
References d_senders.
Referenced by handle_sender_message().
int vrpn_Endpoint::newRemoteType | ( | cName | type_name, |
vrpn_int32 | remote_id, | ||
vrpn_int32 | local_id ) |
Adds a new remote type/sender and returns its index. Returns -1 on error.
Definition at line 3220 of file vrpn_Connection.C.
References d_types.
Referenced by handle_type_message().
int vrpn_Endpoint::openLogs | ( | void | ) |
Definition at line 4521 of file vrpn_Connection.C.
References d_inLog, d_outLog, and vrpn_Log::open().
int vrpn_Endpoint::pack_log_description | ( | void | ) |
Packs the log description set by setup_new_connection().
Definition at line 3452 of file vrpn_Connection.C.
References d_remoteInLogName, d_remoteLogMode, d_remoteOutLogName, pack_message(), vrpn_buffer(), vrpn_CONNECTION_LOG_DESCRIPTION, vrpn_CONNECTION_RELIABLE, and vrpn_gettimeofday.
Referenced by vrpn_Endpoint_IP::finish_new_connection_setup().
|
pure virtual |
Pack a message that will be sent the next time mainloop() is called. Turn off the RELIABLE flag if you want low-latency (UDP) send.
Implemented in vrpn_Endpoint_IP.
Referenced by pack_log_description(), pack_sender_description(), and pack_type_description().
int vrpn_Endpoint::pack_sender_description | ( | vrpn_int32 | which | ) |
Packs a sender description over our socket.
Definition at line 4613 of file vrpn_Connection.C.
References d_dispatcher, pack_message(), vrpn_CONNECTION_RELIABLE, vrpn_CONNECTION_SENDER_DESCRIPTION, and vrpn_gettimeofday.
Referenced by vrpn_Endpoint_IP::finish_new_connection_setup().
int vrpn_Endpoint::pack_type_description | ( | vrpn_int32 | which | ) |
Packs a type description.
Definition at line 4583 of file vrpn_Connection.C.
References d_dispatcher, pack_message(), vrpn_CONNECTION_RELIABLE, vrpn_CONNECTION_TYPE_DESCRIPTION, and vrpn_gettimeofday.
Referenced by vrpn_Endpoint_IP::finish_new_connection_setup().
|
pure virtual |
Implemented in vrpn_Endpoint_IP.
|
pure virtual |
send pending report, clear the buffer. This function was protected, now is public, so we can use it to send out intermediate results without calling mainloop
Implemented in vrpn_Endpoint_IP.
Referenced by tryToMarshall().
|
inline |
Definition at line 377 of file vrpn_Connection.h.
Referenced by vrpn_Connection_IP::connect_to_client(), vrpn_Connection_IP::server_check_for_incoming_connections(), vrpn_Connection::vrpn_Connection(), and vrpn_Connection::vrpn_Connection().
void vrpn_Endpoint::setLogNames | ( | const char * | inName, |
const char * | outName ) |
Definition at line 4511 of file vrpn_Connection.C.
References d_inLog, d_outLog, and vrpn_Log::setName().
Referenced by vrpn_Connection::handle_log_message().
|
pure virtual |
Sends the magic cookie and other information to its peer. It is called by both the client and server setup routines.
Implemented in vrpn_Endpoint_IP.
Referenced by vrpn_Connection_IP::handle_connection().
|
protected |
Calls marshall_message(); if that fails, calls send_pending_reports() and then marshalls again. Returns the number of characters successfully marshalled.
Definition at line 4343 of file vrpn_Connection.C.
References marshall_message(), and send_pending_reports().
Referenced by vrpn_Endpoint_IP::pack_message().
|
protected |
Definition at line 409 of file vrpn_Connection.h.
Referenced by vrpn_Endpoint_IP::drop_connection(), and vrpn_Endpoint_IP::finish_new_connection_setup().
|
protected |
Definition at line 408 of file vrpn_Connection.h.
Referenced by dispatch(), vrpn_Endpoint_IP::drop_connection(), vrpn_Endpoint_IP::finish_new_connection_setup(), handle_sender_message(), handle_type_message(), pack_sender_description(), and pack_type_description().
vrpn_Log* vrpn_Endpoint::d_inLog |
Definition at line 357 of file vrpn_Connection.h.
Referenced by vrpn_Endpoint_IP::finish_new_connection_setup(), vrpn_Connection::get_log_names(), vrpn_Endpoint_IP::getOneTCPMessage(), vrpn_Endpoint_IP::getOneUDPMessage(), vrpn_Connection::handle_log_message(), init(), openLogs(), vrpn_File_Connection::playone_to_filetime(), vrpn_File_Connection::read_cookie(), vrpn_Connection_IP::server_check_for_incoming_connections(), setLogNames(), vrpn_Connection::vrpn_Connection(), and ~vrpn_Endpoint().
vrpn_Log* vrpn_Endpoint::d_outLog |
Definition at line 358 of file vrpn_Connection.h.
Referenced by vrpn_Endpoint_IP::drop_connection(), vrpn_Endpoint_IP::finish_new_connection_setup(), vrpn_Connection::get_log_names(), vrpn_Connection::handle_log_message(), init(), openLogs(), vrpn_Endpoint_IP::pack_message(), setLogNames(), vrpn_Connection::vrpn_Connection(), vrpn_Connection::vrpn_Connection(), and ~vrpn_Endpoint().
|
protected |
Definition at line 411 of file vrpn_Connection.h.
Referenced by handle_sender_message(), vrpn_Endpoint_IP::handle_tcp_messages(), handle_type_message(), and vrpn_Endpoint_IP::handle_udp_messages().
char* vrpn_Endpoint::d_remoteInLogName |
Name of the remote log file.
Definition at line 344 of file vrpn_Connection.h.
Referenced by vrpn_Connection::get_log_names(), pack_log_description(), vrpn_Connection::vrpn_Connection(), vrpn_Connection::vrpn_Connection(), and ~vrpn_Endpoint().
long vrpn_Endpoint::d_remoteLogMode |
Mode to put the remote logging in.
Definition at line 343 of file vrpn_Connection.h.
Referenced by pack_log_description(), vrpn_Endpoint_IP::setup_new_connection(), vrpn_Connection::vrpn_Connection(), and vrpn_Connection::vrpn_Connection().
char* vrpn_Endpoint::d_remoteOutLogName |
Name of the remote log file.
Name of the remote host we are connected to. This is kept for informational purposes. It is printed by the ceiling server, for example.
Definition at line 345 of file vrpn_Connection.h.
Referenced by vrpn_Connection::get_log_names(), pack_log_description(), vrpn_Connection::vrpn_Connection(), vrpn_Connection::vrpn_Connection(), and ~vrpn_Endpoint().
|
protected |
Definition at line 405 of file vrpn_Connection.h.
Referenced by clear_other_senders_and_types(), init(), local_sender_id(), newLocalSender(), newRemoteSender(), and ~vrpn_Endpoint().
|
protected |
Definition at line 406 of file vrpn_Connection.h.
Referenced by clear_other_senders_and_types(), init(), local_type_id(), newLocalType(), newRemoteType(), and ~vrpn_Endpoint().
char vrpn_Endpoint::rhostname[150] |
Definition at line 350 of file vrpn_Connection.h.
Referenced by vrpn_Connection_IP::handle_UDP_message().
int vrpn_Endpoint::status |
Definition at line 337 of file vrpn_Connection.h.
Referenced by vrpn_Endpoint_IP::connect_tcp_to(), vrpn_Connection_IP::connect_to_client(), vrpn_Endpoint_IP::connect_udp_to(), vrpn_Endpoint_IP::doing_okay(), vrpn_Connection_IP::drop_connection(), vrpn_Endpoint_IP::finish_new_connection_setup(), vrpn_Connection::handle_log_message(), vrpn_Connection_IP::handle_UDP_message(), init(), vrpn_Endpoint_IP::mainloop(), vrpn_Endpoint_IP::pack_message(), vrpn_Endpoint_IP::poll_for_cookie(), vrpn_Endpoint_IP::send_pending_reports(), vrpn_Connection_IP::server_check_for_incoming_connections(), vrpn_Endpoint_IP::setNICaddress(), vrpn_Endpoint_IP::setup_new_connection(), vrpn_Connection::vrpn_Connection(), and vrpn_File_Connection::vrpn_File_Connection().