vrpn
07.33
Virtual Reality Peripheral Network
|
Generic connection class not specific to the transport mechanism. More...
#include <vrpn_Connection.h>
Public Member Functions | |
virtual | ~vrpn_Connection (void) |
virtual vrpn_bool | doing_okay (void) const |
Returns vrpn_true if the connection is okay, vrpn_false if not. More... | |
virtual vrpn_bool | connected (void) const |
Returns vrpn_true if the connection has been established, vrpn_false if not (For a networkless connection, this is equivalent to doing_okay()). More... | |
void | get_log_names (char **local_in_logname, char **local_out_logname, char **remote_in_logname, char **remote_out_logname) |
This function returns the logfile names of this connection in the parameters. It will allocate memory for the name of each log file in use. If no logging of a particular type is happening, then *(X_Y_logname) will be set to NULL. IMPORTANT: code calling this function is responsible for freeing the memory allocated for these strings. More... | |
virtual int | mainloop (const struct timeval *timeout=NULL)=0 |
Call each time through program main loop to handle receiving any incoming messages and sending any packed messages. Returns -1 when connection dropped due to error, 0 otherwise. (only returns -1 once per connection drop). Optional argument is TOTAL time to block on select() calls; there may be multiple calls to select() per call to mainloop(), and this timeout will be divided evenly between them. More... | |
virtual vrpn_int32 | register_sender (const char *name) |
Get a token to use for the string name of the sender or type. Remember to check for -1 meaning failure. More... | |
virtual vrpn_int32 | register_message_type (const char *name) |
virtual int | register_handler (vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER) |
Set up (or remove) a handler for a message of a given type. Optionally, specify which sender to handle messages from. Handlers will be called during mainloop(). Your handler should return 0 or a communication error is assumed and the connection will be shut down. More... | |
virtual int | unregister_handler (vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER) |
virtual int | pack_message (vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service) |
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... | |
virtual int | time_since_connection_open (struct timeval *elapsed_time) |
Returns the time since the connection opened. Some subclasses may redefine time. More... | |
virtual timeval | get_time () |
returns the current time in the connection (since the epoch – UTC time). More... | |
virtual const char * | sender_name (vrpn_int32 sender) |
Returns the name of the specified sender/type, or NULL if the parameter is invalid. Only works for user messages (type >= 0). More... | |
virtual const char * | message_type_name (vrpn_int32 type) |
virtual int | register_log_filter (vrpn_LOGFILTER filter, void *userdata) |
Sets up a filter function for logging. Any user message to be logged is first passed to this function, and will only be logged if the function returns zero (XXX). NOTE: this only affects local logging - remote logging is unfiltered! Only user messages are filtered; all system messages are logged. Returns nonzero on failure. More... | |
virtual int | save_log_so_far () |
Save any messages on any endpoints which have been logged so far. More... | |
virtual vrpn_File_Connection * | get_File_Connection (void) |
vrpn_File_Connection implements this as "return this" so it can be used to detect a File_Connection and get the pointer for it More... | |
void | Jane_stop_this_crazy_thing (vrpn_uint32 stop_looking_after) |
This function should be seldom used. It is here for the case of the vrpn_Imager, whose servers do not follow "The VRPN Way" because they try to jam more data into the network than there is bandwidth to support it. As a result, a client may call mainloop() on the connection and have it never return – there is always more data in the network to read, so we never hand control back to the main program. The reason for the name comes from an old U.S. cartoon called "The Jetsons". In it, George Jetson is running on a treadmill when it goes out of control and starts spinning so fast that he can't even run fast enough to reach the controls and turn it off. He cries out to his wife, "Jane! Stop this crazy thing!" The parameter specifies a trigger: if more than the specified number of messages come in on a given input channel during one mainloop() call, the connection should stop looking for more messages. NOTE: this does not guarantee that only this many messages will be received, only that the connection will stop looking for new ones on a given channel once that many have been received (for example, UDP channels will parse all the rest of the messages in a packet before stopping). A value of 0 turns off the limit, and will cause all incoming messages to be handled before returning. More... | |
vrpn_uint32 | get_Jane_value (void) |
void | addReference () |
Counting references to this connection. More... | |
void | removeReference () |
void | setAutoDeleteStatus (bool setvalue) |
Specify whether this connection should be deleted automatically when it is no longer need (reference count reaches zero). For connections created by the VRPN code (as is done in get_connection_by_name) these should be auto-deleted. Connections created by user code should not be auto-deleted; that is up to the user to decide when finished. By default, the constructor sets this to FALSE. VRPN code (or user code) can set this to TRUE if it wants the connection to be deleted automatically when the last service on it is deleted. More... | |
Public Attributes | |
vrpn_TypeDispatcher * | d_dispatcher |
Derived classes need access to d_dispatcher in their allocateEndpoint() routine. Several compilers won't give it to them, even if they do inherit publicly. Until we figure that out, d_dispatcher needs to be public. More... | |
Protected Member Functions | |
vrpn_Connection (const char *local_in_logfile_name, const char *local_out_logfile_name, vrpn_Endpoint_IP *(*epa)(vrpn_Connection *, vrpn_int32 *)=allocateEndpoint) | |
Constructor for server connection. This cannot be called directly any more because vrpn_Connection is an abstract base class. Call vrpn_create_server_connection() to make a server of arbitrary type based on a name. More... | |
vrpn_Connection (const char *local_in_logfile_name, const char *local_out_logfile_name, const char *remote_in_logfile_name, const char *remote_out_logfile_name, vrpn_Endpoint_IP *(*epa)(vrpn_Connection *, vrpn_int32 *)=allocateEndpoint) | |
Constructor for client connection. This cannot be called directly because vrpn_Connection is an abstract base class. Call vrpn_get_connection_by_name() to create a client connection. More... | |
virtual void | init (void) |
Base initialization for all constructors. More... | |
int | delete_endpoint (int whichEndpoint) |
Deletes the endpoint and NULLs the entry in the list of open endpoints. More... | |
int | compact_endpoints (void) |
Makes sure the endpoint array is set up cleanly for the next pass through. More... | |
virtual int | pack_sender_description (vrpn_int32 which) |
Send the sender description to ALL endpoints. More... | |
virtual int | pack_type_description (vrpn_int32 which) |
Send the type description to ALL endpoints. More... | |
virtual int | do_callbacks_for (vrpn_int32 type, vrpn_int32 sender, struct timeval time, vrpn_uint32 len, const char *buffer) |
int | message_type_is_registered (const char *) const |
Returns message type ID, or -1 if unregistered. More... | |
int | doSystemCallbacksFor (vrpn_HANDLERPARAM, void *) |
virtual void | updateEndpoints (void) |
This function will be called on the mainloop() iteration after *d_endpointAllocator is called, which lets subclasses do initialization. (They can't do so during allocateEndpoint because it's called during the Connection constructor when their constructors haven't executed yet.) More... | |
Static Protected Member Functions | |
static vrpn_Endpoint_IP * | allocateEndpoint (vrpn_Connection *, vrpn_int32 *connectedEC) |
Redefining this and passing it to constructors allows a subclass to use a different subclass of Endpoint. It should do NOTHING but return an endpoint of the appropriate class; it may not access subclass data, since it'll be called from a constructor. More... | |
static int VRPN_CALLBACK | handle_log_message (void *userdata, vrpn_HANDLERPARAM p) |
Routines that handle system messages. More... | |
static int VRPN_CALLBACK | handle_disconnect_message (void *userdata, vrpn_HANDLERPARAM p) |
Protected Attributes | |
vrpn_uint32 | d_stop_processing_messages_after |
If this value is greater than zero, the connection should stop looking for new messages on a given endpoint after this many are found. More... | |
int | connectionStatus |
Status of the connection. More... | |
vrpn_Endpoint_IP * | d_endpoints [vrpn_MAX_ENDPOINTS] |
Sockets used to talk to remote Connection(s) and other information needed on a per-connection basis. More... | |
vrpn_int32 | d_numEndpoints |
vrpn_int32 | d_numConnectedEndpoints |
We need to track the number of connected endpoints separately to properly send out got-first-connection/dropped-last-connection messages. This value is managed by the Endpoints, but we need exactly one copy per Connection, so it's on the Connection. More... | |
timeval | start_time |
Timekeeping - TCH 30 June 98. More... | |
int | d_serverLogCount |
Server logging w. multiconnection - TCH July 00 Use one "hidden" endpoint for outgoing logs (?), standard per-endpoint logs with augmented names for incoming. To make a hidden endpoint we create d_endpoints[0] and increment the d_numEndpoints, but DON'T pass it d_numConnectedEndpoints (although it should be safe to do so, since it should never truly become connected, but we might have to "fake" it to get it to log correctly). More... | |
vrpn_int32 | d_serverLogMode |
char * | d_serverLogName |
vrpn_Endpoint_IP *(* | d_endpointAllocator )(vrpn_Connection *, vrpn_int32 *) |
vrpn_bool | d_updateEndpoint |
Generic connection class not specific to the transport mechanism.
It abstracts all of the common functions. Specific implementations for IP, MPI, and other transport mechanisms follow.
Definition at line 510 of file vrpn_Connection.h.
|
protected |
Constructor for server connection. This cannot be called directly any more because vrpn_Connection is an abstract base class. Call vrpn_create_server_connection() to make a server of arbitrary type based on a name.
Definition at line 4824 of file vrpn_Connection.C.
References BROKEN, connectionStatus, d_dispatcher, d_endpoints, d_numEndpoints, vrpn_Endpoint::d_outLog, vrpn_Endpoint::d_remoteInLogName, vrpn_Endpoint::d_remoteLogMode, vrpn_Endpoint::d_remoteOutLogName, d_serverLogMode, d_serverLogName, d_updateEndpoint, handle_log_message(), init(), LOGGING, vrpn_Log::logMode(), vrpn_Log::open(), vrpn_Endpoint::setConnection(), vrpn_Log::setName(), vrpn_Endpoint::status, vrpn_CONNECTION_LOG_DESCRIPTION, and vrpn_LOG_NONE.
|
protected |
Constructor for client connection. This cannot be called directly because vrpn_Connection is an abstract base class. Call vrpn_get_connection_by_name() to create a client connection.
Definition at line 4898 of file vrpn_Connection.C.
References BROKEN, connectionStatus, d_endpoints, vrpn_Endpoint::d_inLog, d_numConnectedEndpoints, d_numEndpoints, vrpn_Endpoint::d_outLog, vrpn_Endpoint::d_remoteInLogName, vrpn_Endpoint::d_remoteLogMode, vrpn_Endpoint::d_remoteOutLogName, d_updateEndpoint, init(), vrpn_Log::logMode(), vrpn_Log::open(), vrpn_Endpoint::setConnection(), vrpn_Log::setName(), vrpn_LOG_INCOMING, vrpn_LOG_NONE, and vrpn_LOG_OUTGOING.
|
virtual |
Definition at line 4996 of file vrpn_Connection.C.
References d_dispatcher.
void vrpn_Connection::addReference | ( | ) |
Counting references to this connection.
Definition at line 5013 of file vrpn_Connection.C.
Referenced by vrpn_SharedObject::bindConnection(), vrpn_ConnectionPtr::operator=(), vrpn_BaseClass::vrpn_BaseClass(), vrpn_ConnectionForwarder::vrpn_ConnectionForwarder(), vrpn_ConnectionPtr::vrpn_ConnectionPtr(), vrpn_create_server_connection(), vrpn_Forwarder_Brain::vrpn_Forwarder_Brain(), vrpn_get_connection_by_name(), vrpn_Mutex::vrpn_Mutex(), vrpn_RedundantReceiver::vrpn_RedundantReceiver(), vrpn_RedundantTransmission::vrpn_RedundantTransmission(), and vrpn_StreamForwarder::vrpn_StreamForwarder().
|
staticprotected |
Redefining this and passing it to constructors allows a subclass to use a different subclass of Endpoint. It should do NOTHING but return an endpoint of the appropriate class; it may not access subclass data, since it'll be called from a constructor.
Definition at line 5175 of file vrpn_Connection.C.
References d_dispatcher.
|
protected |
Makes sure the endpoint array is set up cleanly for the next pass through.
Definition at line 4806 of file vrpn_Connection.C.
References d_endpoints, and d_numEndpoints.
Referenced by vrpn_Connection_IP::mainloop(), and vrpn_Connection_IP::send_pending_reports().
|
virtual |
Returns vrpn_true if the connection has been established, vrpn_false if not (For a networkless connection, this is equivalent to doing_okay()).
Reimplemented in vrpn_Connection_Loopback.
Definition at line 5237 of file vrpn_Connection.C.
References CONNECTED, d_endpoints, and d_numEndpoints.
Referenced by vrpn_Event_Mouse::mainloop(), vrpn_Atmel::mainloop(), and vrpn_Mutex_Remote::vrpn_Mutex_Remote().
|
protected |
Deletes the endpoint and NULLs the entry in the list of open endpoints.
Definition at line 4789 of file vrpn_Connection.C.
References d_endpoints.
Referenced by vrpn_Connection_IP::drop_connection().
|
protectedvirtual |
Definition at line 5121 of file vrpn_Connection.C.
References d_dispatcher.
Referenced by pack_message(), and vrpn_File_Connection::playone_to_filetime().
|
virtual |
Returns vrpn_true if the connection is okay, vrpn_false if not.
Reimplemented in vrpn_Connection_Loopback.
Definition at line 5222 of file vrpn_Connection.C.
References BROKEN, connectionStatus, d_endpoints, and d_numEndpoints.
Referenced by vrpn_Auxiliary_Logger_Server_Generic::handle_request_logging(), and vrpn_Imager_Stream_Buffer::open_new_log_connection().
|
protected |
Definition at line 5128 of file vrpn_Connection.C.
References d_dispatcher.
Referenced by vrpn_File_Connection::playone_to_filetime().
|
virtual |
vrpn_File_Connection implements this as "return this" so it can be used to detect a File_Connection and get the pointer for it
Reimplemented in vrpn_File_Connection.
Definition at line 4747 of file vrpn_Connection.C.
|
inline |
Definition at line 642 of file vrpn_Connection.h.
Referenced by vrpn_Endpoint_IP::handle_tcp_messages(), vrpn_Endpoint_IP::handle_udp_messages(), and vrpn_File_Connection::play_to_filetime().
void vrpn_Connection::get_log_names | ( | char ** | local_in_logname, |
char ** | local_out_logname, | ||
char ** | remote_in_logname, | ||
char ** | remote_out_logname | ||
) |
This function returns the logfile names of this connection in the parameters. It will allocate memory for the name of each log file in use. If no logging of a particular type is happening, then *(X_Y_logname) will be set to NULL. IMPORTANT: code calling this function is responsible for freeing the memory allocated for these strings.
Definition at line 5133 of file vrpn_Connection.C.
References d_endpoints, vrpn_Endpoint::d_inLog, vrpn_Endpoint::d_outLog, vrpn_Endpoint::d_remoteInLogName, vrpn_Endpoint::d_remoteOutLogName, and vrpn_Log::getName().
Referenced by vrpn_Auxiliary_Logger_Server_Generic::handle_request_logging_status().
|
virtual |
returns the current time in the connection (since the epoch – UTC time).
Reimplemented in vrpn_File_Connection.
Definition at line 4702 of file vrpn_Connection.C.
References vrpn_gettimeofday.
|
staticprotected |
Definition at line 5186 of file vrpn_Connection.C.
References vrpn_Endpoint::clear_other_senders_and_types().
Referenced by init().
|
staticprotected |
Routines that handle system messages.
Definition at line 4581 of file vrpn_Connection.C.
References BROKEN, vrpn_HANDLERPARAM::buffer, vrpn_Endpoint::d_inLog, vrpn_Endpoint::d_outLog, vrpn_Log::logMode(), vrpn_Log::open(), vrpn_HANDLERPARAM::sender, vrpn_Endpoint::setLogNames(), vrpn_Endpoint::status, vrpn_LOG_INCOMING, vrpn_LOG_OUTGOING, and vrpn_unbuffer().
Referenced by vrpn_Connection().
|
protectedvirtual |
Base initialization for all constructors.
Reimplemented in vrpn_Connection_IP.
Definition at line 4752 of file vrpn_Connection.C.
References d_dispatcher, d_endpoints, d_stop_processing_messages_after, handle_disconnect_message(), vrpn_Endpoint::handle_sender_message(), vrpn_Endpoint::handle_type_message(), start_time, vrpn_CONNECTION_DISCONNECT_MESSAGE, vrpn_CONNECTION_SENDER_DESCRIPTION, vrpn_CONNECTION_TYPE_DESCRIPTION, vrpn_CONTROL, vrpn_dropped_connection, vrpn_dropped_last_connection, vrpn_gettimeofday, vrpn_got_connection, vrpn_got_first_connection, vrpn_MAX_ENDPOINTS, and vrpn_TypeDispatcher.
Referenced by vrpn_Connection().
|
inline |
This function should be seldom used. It is here for the case of the vrpn_Imager, whose servers do not follow "The VRPN Way" because they try to jam more data into the network than there is bandwidth to support it. As a result, a client may call mainloop() on the connection and have it never return – there is always more data in the network to read, so we never hand control back to the main program. The reason for the name comes from an old U.S. cartoon called "The Jetsons". In it, George Jetson is running on a treadmill when it goes out of control and starts spinning so fast that he can't even run fast enough to reach the controls and turn it off. He cries out to his wife, "Jane! Stop this crazy thing!" The parameter specifies a trigger: if more than the specified number of messages come in on a given input channel during one mainloop() call, the connection should stop looking for more messages. NOTE: this does not guarantee that only this many messages will be received, only that the connection will stop looking for new ones on a given channel once that many have been received (for example, UDP channels will parse all the rest of the messages in a packet before stopping). A value of 0 turns off the limit, and will cause all incoming messages to be handled before returning.
Definition at line 638 of file vrpn_Connection.h.
Referenced by vrpn_File_Connection::limit_messages_played_back().
|
pure virtual |
Call each time through program main loop to handle receiving any incoming messages and sending any packed messages. Returns -1 when connection dropped due to error, 0 otherwise. (only returns -1 once per connection drop). Optional argument is TOTAL time to block on select() calls; there may be multiple calls to select() per call to mainloop(), and this timeout will be divided evenly between them.
Implemented in vrpn_Connection_Loopback, and vrpn_Connection_IP.
Referenced by vrpn_Imager_Stream_Buffer::logging_thread_func(), vrpn_Mutex::mainloop(), vrpn_Event_Mouse::mainloop(), vrpn_Android_Server::mainloop(), vrpn_Atmel::mainloop(), vrpn_Dial_Remote::mainloop(), vrpn_Forwarder_Server::mainloop(), vrpn_Poser_Remote::mainloop(), vrpn_Analog_Output_Remote::mainloop(), vrpn_Analog_Remote::mainloop(), vrpn_PeerMutex::mainloop(), vrpn_Auxiliary_Logger_Remote::mainloop(), vrpn_Button_Remote::mainloop(), vrpn_Sound_Client::mainloop(), vrpn_FunctionGenerator_Remote::mainloop(), vrpn_Tracker_Remote::mainloop(), vrpn_ForceDevice_Remote::mainloop(), vrpn_Imager_Remote::mainloop(), vrpn_ImagerPose_Remote::mainloop(), and vrpn_Imager_Stream_Buffer::make_new_logging_connection().
|
protected |
Returns message type ID, or -1 if unregistered.
Definition at line 5213 of file vrpn_Connection.C.
References d_dispatcher.
|
virtual |
Definition at line 4718 of file vrpn_Connection.C.
References d_dispatcher.
|
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.
Definition at line 4632 of file vrpn_Connection.C.
References BROKEN, connectionStatus, d_dispatcher, d_endpoints, d_numEndpoints, and do_callbacks_for().
Referenced by vrpn_ForceDevice_Remote::addObject(), vrpn_ForceDevice_Remote::addObjectExScene(), vrpn_SharedObject::becomeSerializer(), vrpn_ForceDevice_Remote::clearObjectTrimesh(), vrpn_BaseClassUnique::client_mainloop(), vrpn_Poser_Remote::client_send_pose(), vrpn_Poser_Remote::client_send_pose_relative(), vrpn_Poser_Remote::client_send_pose_velocity(), vrpn_Poser_Remote::client_send_pose_velocity_relative(), vrpn_RedundantRemote::enable(), vrpn_Forwarder_Controller::forward_message_type(), vrpn_Poser_Analog::handle_change_message(), vrpn_SharedObject::handle_grantSerializer(), vrpn_Mutex_Server::handle_requestIndex(), vrpn_SharedObject::handle_requestSerializer(), vrpn_Tracker::handle_t2r_request(), vrpn_Tracker::handle_u2s_request(), vrpn_Poser_Analog::handle_vel_change_message(), vrpn_Tracker::handle_workspace_request(), vrpn_Tracker_GameTrak::mainloop(), vrpn_Tracker_JoyFly::mainloop(), vrpn_RedundantTransmission::mainloop(), vrpn_Tracker_AnalogFly::mainloop(), vrpn_Tracker_ButtonFly::mainloop(), vrpn_Tracker_NULL::mainloop(), vrpn_Imager_Stream_Buffer::mainloop(), vrpn_ForceDevice_Remote::moveToParent(), vrpn_Tracker_Wintracker::on_data_received(), vrpn_Tracker_SpacePoint::on_data_received(), vrpn_Tracker_OSVRHackerDevKit::on_data_received(), vrpn_Auxiliary_Logger::pack_log_message_of_type(), vrpn_RedundantTransmission::pack_message(), vrpn_File_Controller::play_to_time(), vrpn_ForceDevice_Remote::removeObject(), vrpn_ForceDevice_Remote::removeObjectTriangle(), vrpn_Dial::report(), vrpn_Analog::report(), vrpn_Tracker_WiimoteHead::report(), vrpn_Dial::report_changes(), vrpn_3DMicroscribe::report_changes(), vrpn_Analog_Output_Server::report_num_channels(), vrpn_National_Instruments_Server::report_num_channels(), vrpn_Analog_Output_Server_NI::report_num_channels(), vrpn_Tracker_Server::report_pose(), vrpn_Tracker_Server::report_pose_acceleration(), vrpn_Tracker_Server::report_pose_velocity(), vrpn_Button::report_states(), vrpn_Analog_Output_Remote::request_change_channel_value(), vrpn_Analog_Output_Remote::request_change_channels(), vrpn_Tracker_Remote::request_t2r_xform(), vrpn_Tracker_Remote::request_u2s_xform(), vrpn_Tracker_Remote::request_workspace(), vrpn_FunctionGenerator_Remote::requestAllChannels(), vrpn_FunctionGenerator_Remote::requestChannel(), vrpn_FunctionGenerator_Remote::requestInterpreterDescription(), vrpn_FunctionGenerator_Remote::requestSampleRate(), vrpn_FunctionGenerator_Remote::requestStart(), vrpn_FunctionGenerator_Remote::requestStop(), vrpn_File_Controller::reset(), vrpn_Tracker_Remote::reset_origin(), vrpn_ForceDevice_Remote::send(), vrpn_Imager_Server::send_begin_frame(), vrpn_Imager_Server::send_description(), vrpn_ImagerPose_Server::send_description(), vrpn_Imager_Server::send_discarded_frames(), vrpn_Imager_Server::send_end_frame(), vrpn_Imager_Server::send_region_using_base_pointer(), vrpn_Tracker_TrivisioColibri::send_report(), vrpn_Tracker_InterSense::send_report(), vrpn_Tracker_PhaseSpace::send_report(), vrpn_Tracker_Crossbow::send_report(), vrpn_Tracker_NDI_Polaris::send_report(), vrpn_Tracker_Serial::send_report(), vrpn_Tracker_USB::send_report(), vrpn_BaseClassUnique::send_text_message(), vrpn_FunctionGenerator_Server::sendChannelReply(), vrpn_Mutex::sendDenyRequest(), vrpn_PeerMutex::sendDenyRequest(), vrpn_ForceDevice::sendError(), vrpn_FunctionGenerator_Server::sendError(), vrpn_ForceDevice_Remote::sendForceField(), vrpn_Mutex::sendGrantRequest(), vrpn_PeerMutex::sendGrantRequest(), vrpn_FunctionGenerator_Server::sendInterpreterDescription(), vrpn_Mutex::sendRelease(), vrpn_PeerMutex::sendRelease(), vrpn_Mutex::sendReleaseNotification(), vrpn_Mutex::sendRequest(), vrpn_PeerMutex::sendRequest(), vrpn_FunctionGenerator_Server::sendSampleRateReply(), vrpn_FunctionGenerator_Server::sendStartReply(), vrpn_FunctionGenerator_Server::sendStopReply(), vrpn_ForceDevice_Remote::sendSurface(), vrpn_Shared_int32::sendUpdate(), vrpn_Shared_float64::sendUpdate(), vrpn_Shared_String::sendUpdate(), vrpn_RedundantRemote::set(), vrpn_File_Controller::set_replay_rate(), vrpn_Tracker_Remote::set_update_rate(), vrpn_FunctionGenerator_Remote::setChannel(), vrpn_ForceDevice_Remote::setHapticOrigin(), vrpn_ForceDevice_Remote::setHapticScale(), vrpn_ForceDevice_Remote::setObjectIsTouchable(), vrpn_ForceDevice_Remote::setObjectNormal(), vrpn_ForceDevice_Remote::setObjectOrientation(), vrpn_ForceDevice_Remote::setObjectPosition(), vrpn_ForceDevice_Remote::setObjectScale(), vrpn_ForceDevice_Remote::setObjectTriangle(), vrpn_ForceDevice_Remote::setObjectTrimeshTransform(), vrpn_ForceDevice_Remote::setObjectVertex(), vrpn_ForceDevice_Remote::setSceneOrigin(), vrpn_Forwarder_Controller::start_remote_forwarding(), vrpn_ForceDevice_Remote::startEffect(), vrpn_ForceDevice_Remote::startSurface(), vrpn_ForceDevice_Remote::stopEffect(), vrpn_ForceDevice_Remote::stopForceField(), vrpn_ForceDevice_Remote::stopSurface(), vrpn_Imager_Remote::throttle_sender(), vrpn_ForceDevice_Remote::updateObjectTrimeshChanges(), vrpn_ForceDevice_Remote::useGhost(), and vrpn_ForceDevice_Remote::useHcollide().
|
protectedvirtual |
Send the sender description to ALL endpoints.
Definition at line 4563 of file vrpn_Connection.C.
References d_endpoints, d_numEndpoints, and vrpn_Endpoint::pack_sender_description().
Referenced by register_sender().
|
protectedvirtual |
Send the type description to ALL endpoints.
Definition at line 4546 of file vrpn_Connection.C.
References d_endpoints, d_numEndpoints, and vrpn_Endpoint::pack_type_description().
Referenced by register_message_type().
|
virtual |
Set up (or remove) a handler for a message of a given type. Optionally, specify which sender to handle messages from. Handlers will be called during mainloop(). Your handler should return 0 or a communication error is assumed and the connection will be shut down.
Definition at line 5199 of file vrpn_Connection.C.
References d_dispatcher.
Referenced by vrpn_TextPrinter::add_object(), vrpn_PeerMutex::addPeer(), vrpn_ConnectionForwarder::forward(), vrpn_StreamForwarder::forward(), vrpn_BaseClassUnique::register_autodeleted_handler(), vrpn_RedundantReceiver::register_handler(), vrpn_Imager_Stream_Buffer::setup_handlers_for_logging_connection(), vrpn_File_Connection::vrpn_File_Connection(), vrpn_Forwarder_Server::vrpn_Forwarder_Server(), vrpn_Mutex_Remote::vrpn_Mutex_Remote(), vrpn_Mutex_Server::vrpn_Mutex_Server(), and vrpn_Tracker_JoyFly::vrpn_Tracker_JoyFly().
|
virtual |
Sets up a filter function for logging. Any user message to be logged is first passed to this function, and will only be logged if the function returns zero (XXX). NOTE: this only affects local logging - remote logging is unfiltered! Only user messages are filtered; all system messages are logged. Returns nonzero on failure.
Definition at line 4724 of file vrpn_Connection.C.
References vrpn_Log::addFilter(), d_endpoints, vrpn_Endpoint::d_inLog, d_numEndpoints, and vrpn_Endpoint::d_outLog.
|
virtual |
Definition at line 5074 of file vrpn_Connection.C.
References d_dispatcher, d_endpoints, d_numEndpoints, vrpn_Endpoint::newLocalType(), and pack_type_description().
Referenced by vrpn_PeerMutex::addPeer(), vrpn_SharedObject::bindConnection(), vrpn_BaseClassUnique::client_mainloop(), vrpn_Endpoint::handle_type_message(), vrpn_PeerMutex::init(), vrpn_BaseClass::init(), vrpn_Retrolink::init_hid(), vrpn_CHProducts_Controller_Raw::init_hid(), vrpn_Saitek_Controller_Raw::init_hid(), vrpn_Logitech_Controller_Raw::init_hid(), vrpn_Futaba::init_hid(), vrpn_Contour::init_hid(), vrpn_Griffin::init_hid(), vrpn_Xkeys::init_hid(), vrpn_Microsoft_Controller_Raw::init_hid(), vrpn_Dial::register_types(), vrpn_Auxiliary_Logger::register_types(), vrpn_Analog::register_types(), vrpn_Analog_Output::register_types(), vrpn_Poser::register_types(), vrpn_Button::register_types(), vrpn_RedundantController_Protocol::register_types(), vrpn_Tracker::register_types(), vrpn_Imager::register_types(), vrpn_Sound::register_types(), vrpn_ForceDevice::register_types(), vrpn_FunctionGenerator::register_types(), vrpn_ImagerPose::register_types(), vrpn_PeerMutex::sendDenyRequest(), vrpn_PeerMutex::sendGrantRequest(), vrpn_PeerMutex::sendRelease(), vrpn_PeerMutex::sendRequest(), vrpn_Imager_Stream_Buffer::setup_handlers_for_logging_connection(), vrpn_ConnectionForwarder::unforward(), vrpn_StreamForwarder::unforward(), vrpn_Auxiliary_Logger_Server::vrpn_Auxiliary_Logger_Server(), vrpn_File_Controller::vrpn_File_Controller(), vrpn_Forwarder_Brain::vrpn_Forwarder_Brain(), vrpn_GlobalHapticsOrb::vrpn_GlobalHapticsOrb(), vrpn_Imager_Remote::vrpn_Imager_Remote(), vrpn_Imager_Server::vrpn_Imager_Server(), vrpn_Imager_Stream_Buffer::vrpn_Imager_Stream_Buffer(), vrpn_ImagerPose_Server::vrpn_ImagerPose_Server(), vrpn_Mutex::vrpn_Mutex(), vrpn_Mutex_Remote::vrpn_Mutex_Remote(), vrpn_Mutex_Server::vrpn_Mutex_Server(), vrpn_raw_SGIBox::vrpn_raw_SGIBox(), vrpn_Tracker_JoyFly::vrpn_Tracker_JoyFly(), vrpn_Tracker_WiimoteHead::vrpn_Tracker_WiimoteHead(), vrpn_WiiMote::vrpn_WiiMote(), vrpn_Mutex_Remote::~vrpn_Mutex_Remote(), vrpn_Mutex_Server::~vrpn_Mutex_Server(), and vrpn_SharedObject::~vrpn_SharedObject().
|
virtual |
Get a token to use for the string name of the sender or type. Remember to check for -1 meaning failure.
Definition at line 5032 of file vrpn_Connection.C.
References d_dispatcher, d_endpoints, d_numEndpoints, vrpn_Endpoint::newLocalSender(), and pack_sender_description().
Referenced by vrpn_PeerMutex::addPeer(), vrpn_SharedObject::bindConnection(), vrpn_Endpoint::handle_sender_message(), vrpn_PeerMutex::init(), vrpn_BaseClass::register_senders(), vrpn_Imager_Stream_Buffer::setup_handlers_for_logging_connection(), vrpn_Imager_Stream_Buffer::teardown_handlers_for_logging_connection(), vrpn_ConnectionForwarder::unforward(), vrpn_File_Controller::vrpn_File_Controller(), vrpn_Forwarder_Brain::vrpn_Forwarder_Brain(), and vrpn_Mutex::vrpn_Mutex().
void vrpn_Connection::removeReference | ( | ) |
Definition at line 5020 of file vrpn_Connection.C.
Referenced by vrpn_SharedObject::bindConnection(), vrpn_PeerMutex::handle_losePeer(), vrpn_Auxiliary_Logger_Server_Generic::handle_request_logging(), vrpn_Imager_Stream_Buffer::logging_thread_func(), vrpn_Imager_Stream_Buffer::make_new_logging_connection(), vrpn_ConnectionPtr::reset(), vrpn_BaseClassUnique::~vrpn_BaseClassUnique(), vrpn_ConnectionForwarder::~vrpn_ConnectionForwarder(), vrpn_Forwarder_Brain::~vrpn_Forwarder_Brain(), vrpn_Mutex::~vrpn_Mutex(), vrpn_PeerMutex::~vrpn_PeerMutex(), vrpn_RedundantReceiver::~vrpn_RedundantReceiver(), vrpn_RedundantTransmission::~vrpn_RedundantTransmission(), vrpn_SharedObject::~vrpn_SharedObject(), and vrpn_StreamForwarder::~vrpn_StreamForwarder().
|
virtual |
Save any messages on any endpoints which have been logged so far.
Definition at line 4735 of file vrpn_Connection.C.
References d_endpoints, vrpn_Endpoint::d_inLog, d_numEndpoints, vrpn_Endpoint::d_outLog, and vrpn_Log::saveLogSoFar().
Referenced by vrpn_Imager_Stream_Buffer::logging_thread_func(), and vrpn_Imager_Stream_Buffer::make_new_logging_connection().
|
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_Connection_Loopback, vrpn_Connection_IP, and vrpn_File_Connection.
Referenced by vrpn_3DConnexion::mainloop(), and vrpn_RedundantTransmission::pack_message().
|
virtual |
Returns the name of the specified sender/type, or NULL if the parameter is invalid. Only works for user messages (type >= 0).
Definition at line 4712 of file vrpn_Connection.C.
References d_dispatcher.
Referenced by vrpn_TextPrinter::text_message_handler().
|
inline |
Specify whether this connection should be deleted automatically when it is no longer need (reference count reaches zero). For connections created by the VRPN code (as is done in get_connection_by_name) these should be auto-deleted. Connections created by user code should not be auto-deleted; that is up to the user to decide when finished. By default, the constructor sets this to FALSE. VRPN code (or user code) can set this to TRUE if it wants the connection to be deleted automatically when the last service on it is deleted.
Definition at line 724 of file vrpn_Connection.h.
Referenced by vrpn_create_server_connection(), and vrpn_get_connection_by_name().
|
virtual |
Returns the time since the connection opened. Some subclasses may redefine time.
Reimplemented in vrpn_File_Connection.
Definition at line 4691 of file vrpn_Connection.C.
References start_time, vrpn_gettimeofday, and vrpn_TimevalDiff().
|
virtual |
Definition at line 5206 of file vrpn_Connection.C.
References d_dispatcher.
Referenced by vrpn_TextPrinter::remove_object(), vrpn_Imager_Stream_Buffer::teardown_handlers_for_logging_connection(), vrpn_BaseClassUnique::~vrpn_BaseClassUnique(), vrpn_ConnectionForwarder::~vrpn_ConnectionForwarder(), vrpn_Forwarder_Server::~vrpn_Forwarder_Server(), vrpn_Mutex_Remote::~vrpn_Mutex_Remote(), vrpn_Mutex_Server::~vrpn_Mutex_Server(), vrpn_SharedObject::~vrpn_SharedObject(), vrpn_StreamForwarder::~vrpn_StreamForwarder(), and vrpn_TextPrinter::~vrpn_TextPrinter().
|
protectedvirtual |
This function will be called on the mainloop() iteration after *d_endpointAllocator is called, which lets subclasses do initialization. (They can't do so during allocateEndpoint because it's called during the Connection constructor when their constructors haven't executed yet.)
Definition at line 5172 of file vrpn_Connection.C.
Referenced by vrpn_Connection_IP::mainloop().
|
protected |
Status of the connection.
Definition at line 653 of file vrpn_Connection.h.
Referenced by vrpn_Connection_IP::connect_to_client(), doing_okay(), vrpn_Connection_IP::mainloop(), pack_message(), vrpn_Connection_IP::server_check_for_incoming_connections(), vrpn_Connection(), vrpn_Connection_IP::vrpn_Connection_IP(), vrpn_Connection_Loopback::vrpn_Connection_Loopback(), and vrpn_File_Connection::vrpn_File_Connection().
vrpn_TypeDispatcher* vrpn_Connection::d_dispatcher |
Derived classes need access to d_dispatcher in their allocateEndpoint() routine. Several compilers won't give it to them, even if they do inherit publicly. Until we figure that out, d_dispatcher needs to be public.
Definition at line 735 of file vrpn_Connection.h.
Referenced by allocateEndpoint(), do_callbacks_for(), doSystemCallbacksFor(), init(), vrpn_Connection_IP::init(), message_type_is_registered(), message_type_name(), pack_message(), register_handler(), register_message_type(), register_sender(), sender_name(), unregister_handler(), vrpn_Connection(), and ~vrpn_Connection().
|
protected |
Definition at line 754 of file vrpn_Connection.h.
|
protected |
Sockets used to talk to remote Connection(s) and other information needed on a per-connection basis.
Definition at line 665 of file vrpn_Connection.h.
Referenced by compact_endpoints(), vrpn_Connection_IP::connect_to_client(), connected(), delete_endpoint(), doing_okay(), vrpn_Connection_IP::drop_connection(), get_log_names(), vrpn_Connection_IP::handle_connection(), init(), vrpn_Connection_IP::mainloop(), pack_message(), pack_sender_description(), pack_type_description(), vrpn_File_Connection::playone_to_filetime(), vrpn_File_Connection::read_cookie(), register_log_filter(), register_message_type(), register_sender(), vrpn_File_Connection::reset(), save_log_so_far(), vrpn_File_Connection::send_pending_reports(), vrpn_Connection_IP::send_pending_reports(), vrpn_Connection_IP::server_check_for_incoming_connections(), vrpn_Connection(), vrpn_Connection_IP::vrpn_Connection_IP(), vrpn_File_Connection::vrpn_File_Connection(), and vrpn_Connection_IP::~vrpn_Connection_IP().
|
protected |
We need to track the number of connected endpoints separately to properly send out got-first-connection/dropped-last-connection messages. This value is managed by the Endpoints, but we need exactly one copy per Connection, so it's on the Connection.
Definition at line 668 of file vrpn_Connection.h.
Referenced by vrpn_Connection_IP::connect_to_client(), vrpn_Connection_IP::server_check_for_incoming_connections(), and vrpn_Connection().
|
protected |
Definition at line 666 of file vrpn_Connection.h.
Referenced by compact_endpoints(), vrpn_Connection_IP::connect_to_client(), connected(), doing_okay(), vrpn_Connection_IP::mainloop(), pack_message(), pack_sender_description(), pack_type_description(), register_log_filter(), register_message_type(), register_sender(), save_log_so_far(), vrpn_Connection_IP::send_pending_reports(), vrpn_Connection_IP::server_check_for_incoming_connections(), vrpn_Connection(), and vrpn_Connection_IP::~vrpn_Connection_IP().
|
protected |
Server logging w. multiconnection - TCH July 00 Use one "hidden" endpoint for outgoing logs (?), standard per-endpoint logs with augmented names for incoming. To make a hidden endpoint we create d_endpoints[0] and increment the d_numEndpoints, but DON'T pass it d_numConnectedEndpoints (although it should be safe to do so, since it should never truly become connected, but we might have to "fake" it to get it to log correctly).
Definition at line 750 of file vrpn_Connection.h.
Referenced by vrpn_Connection_IP::server_check_for_incoming_connections().
|
protected |
Definition at line 751 of file vrpn_Connection.h.
Referenced by vrpn_Connection_IP::server_check_for_incoming_connections(), and vrpn_Connection().
|
protected |
Definition at line 752 of file vrpn_Connection.h.
Referenced by vrpn_Connection_IP::server_check_for_incoming_connections(), and vrpn_Connection().
|
protected |
If this value is greater than zero, the connection should stop looking for new messages on a given endpoint after this many are found.
Definition at line 645 of file vrpn_Connection.h.
Referenced by init().
|
protected |
Definition at line 755 of file vrpn_Connection.h.
Referenced by vrpn_Connection_IP::connect_to_client(), vrpn_Connection_IP::mainloop(), vrpn_Connection_IP::server_check_for_incoming_connections(), and vrpn_Connection().
|
protected |
Timekeeping - TCH 30 June 98.
Definition at line 701 of file vrpn_Connection.h.
Referenced by init(), and time_since_connection_open().