|
vrpn
07.33
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. More... | |
| 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 More... | |
| int | pack_log_description (void) |
| Packs the log description set by setup_new_connection(). More... | |
| 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. More... | |
| 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. More... | |
| virtual void | clearBuffers (void)=0 |
| Empties out the TCP and UDP send buffers. < Needed by vrpn_FileConnection to get at {udp,tcp}NumOut. More... | |
| int | pack_sender_description (vrpn_int32 which) |
| Packs a sender description over our socket. More... | |
| int | pack_type_description (vrpn_int32 which) |
| Packs a type description. More... | |
Accessors | |
| int | local_type_id (vrpn_int32 remote_type) const |
| Returns the local mapping for the remote type (-1 if none). More... | |
| int | local_sender_id (vrpn_int32 remote_sender) const |
| Returns the local mapping for the remote sender (-1 if none). More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| char * | d_remoteInLogName |
| Name of the remote log file. More... | |
| char * | d_remoteOutLogName |
| Name of the remote log file. More... | |
| 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. More... | |
| 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. More... | |
Protected Attributes | |
| vrpn_TranslationTable * | d_senders |
| vrpn_TranslationTable * | d_types |
| vrpn_TypeDispatcher * | d_dispatcher |
| vrpn_int32 * | d_connectionCounter |
| vrpn_Connection * | d_parent |
Logging | |
| 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 200 of file vrpn_Connection.h.
| vrpn_Endpoint::vrpn_Endpoint | ( | vrpn_TypeDispatcher * | dispatcher, |
| vrpn_int32 * | connectedEndpointCounter | ||
| ) |
Definition at line 2634 of file vrpn_Connection.C.
References init().

|
virtual |
Definition at line 2677 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 3022 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 4168 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 325 of file vrpn_Connection.h.
References vrpn_HANDLERPARAM::payload_len.
|
static |
Definition at line 4388 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.
Referenced by vrpn_Connection::init().

|
static |
Definition at line 4316 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.
Referenced by vrpn_Connection::init().

| void vrpn_Endpoint::init | ( | void | ) |
Definition at line 2774 of file vrpn_Connection.C.
References d_inLog, d_outLog, d_senders, d_types, 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 2760 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 2755 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.
Referenced by vrpn_Connection_IP::mainloop().
|
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 4234 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 3032 of file vrpn_Connection.C.
References d_senders.
| int vrpn_Endpoint::newLocalType | ( | const char * | name, |
| vrpn_int32 | which | ||
| ) |
Definition at line 3041 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 3054 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 3047 of file vrpn_Connection.C.
References d_types.
Referenced by handle_type_message().
| int vrpn_Endpoint::openLogs | ( | void | ) |
Definition at line 4374 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 3277 of file vrpn_Connection.C.
References d_remoteInLogName, d_remoteLogMode, d_remoteOutLogName, vrpn_Endpoint_IP::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.
| int vrpn_Endpoint::pack_sender_description | ( | vrpn_int32 | which | ) |
Packs a sender description over our socket.
Definition at line 4466 of file vrpn_Connection.C.
References d_dispatcher, vrpn_Endpoint_IP::pack_message(), SOCKET, vrpn_CONNECTION_RELIABLE, vrpn_CONNECTION_SENDER_DESCRIPTION, vrpn_gettimeofday, and vrpn_noint_select().
Referenced by vrpn_Endpoint_IP::finish_new_connection_setup(), and vrpn_Connection::register_sender().

| int vrpn_Endpoint::pack_type_description | ( | vrpn_int32 | which | ) |
Packs a type description.
Definition at line 4436 of file vrpn_Connection.C.
References d_dispatcher, vrpn_Endpoint_IP::pack_message(), vrpn_CONNECTION_RELIABLE, vrpn_CONNECTION_TYPE_DESCRIPTION, and vrpn_gettimeofday.
Referenced by vrpn_Endpoint_IP::finish_new_connection_setup(), and vrpn_Connection::register_message_type().

|
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.
|
inline |
Definition at line 324 of file vrpn_Connection.h.
Referenced by vrpn_Connection::compact_endpoints().
| void vrpn_Endpoint::setLogNames | ( | const char * | inName, |
| const char * | outName | ||
| ) |
Definition at line 4364 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 4199 of file vrpn_Connection.C.
References marshall_message(), and vrpn_Endpoint_IP::send_pending_reports().
Referenced by vrpn_Endpoint_IP::pack_message().

|
protected |
Definition at line 356 of file vrpn_Connection.h.
Referenced by vrpn_Endpoint_IP::drop_connection(), and vrpn_Endpoint_IP::finish_new_connection_setup().
|
protected |
Definition at line 355 of file vrpn_Connection.h.
Referenced by vrpn_Connection::compact_endpoints(), dispatch(), vrpn_Connection::do_callbacks_for(), vrpn_Connection::doSystemCallbacksFor(), vrpn_Endpoint_IP::drop_connection(), vrpn_Endpoint_IP::finish_new_connection_setup(), handle_sender_message(), handle_type_message(), vrpn_Connection::init(), vrpn_Connection_IP::init(), vrpn_Connection::message_type_is_registered(), vrpn_Connection::message_type_name(), vrpn_Connection::pack_message(), pack_sender_description(), pack_type_description(), vrpn_Connection::register_handler(), vrpn_Connection::register_message_type(), vrpn_Connection::register_sender(), vrpn_Connection::sender_name(), vrpn_Connection::unregister_handler(), and vrpn_Connection::~vrpn_Connection().
| vrpn_Log* vrpn_Endpoint::d_inLog |
Definition at line 304 of file vrpn_Connection.h.
Referenced by vrpn_Connection::compact_endpoints(), 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(), and ~vrpn_Endpoint().
| vrpn_Log* vrpn_Endpoint::d_outLog |
Definition at line 305 of file vrpn_Connection.h.
Referenced by vrpn_Connection::compact_endpoints(), 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(), and ~vrpn_Endpoint().
|
protected |
Definition at line 358 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 291 of file vrpn_Connection.h.
Referenced by vrpn_Connection::compact_endpoints(), vrpn_Connection::get_log_names(), pack_log_description(), and ~vrpn_Endpoint().
| long vrpn_Endpoint::d_remoteLogMode |
Mode to put the remote logging in.
Definition at line 290 of file vrpn_Connection.h.
Referenced by vrpn_Connection::compact_endpoints(), pack_log_description(), and vrpn_Endpoint_IP::setup_new_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 292 of file vrpn_Connection.h.
Referenced by vrpn_Connection::compact_endpoints(), vrpn_Connection::get_log_names(), pack_log_description(), and ~vrpn_Endpoint().
|
protected |
Definition at line 352 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 353 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 297 of file vrpn_Connection.h.
Referenced by vrpn_Connection_IP::handle_UDP_message().
| int vrpn_Endpoint::status |
Definition at line 284 of file vrpn_Connection.h.
Referenced by vrpn_Connection::compact_endpoints(), vrpn_Endpoint_IP::connect_tcp_to(), vrpn_Connection_IP::connect_to_client(), vrpn_Endpoint_IP::connect_udp_to(), vrpn_Connection::connected(), 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(), vrpn_Endpoint_IP::mainloop(), vrpn_Connection_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::setup_new_connection(), and vrpn_File_Connection::vrpn_File_Connection().