vrpn 07.35
Virtual Reality Peripheral Network
 
Loading...
Searching...
No Matches
vrpn_Endpoint Class Referenceabstract

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>

Inheritance diagram for vrpn_Endpoint:
Collaboration diagram for vrpn_Endpoint:

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_ConnectiongetConnection ()
 

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_TranslationTabled_senders
 
vrpn_TranslationTabled_types
 
vrpn_TypeDispatcherd_dispatcher
 
vrpn_int32 * d_connectionCounter
 
vrpn_Connectiond_parent
 

Logging

TCH 19 April 00; changed into two logs 16 Feb 01

vrpn_Logd_inLog
 
vrpn_Logd_outLog
 
void setLogNames (const char *inName, const char *outName)
 
int openLogs (void)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ vrpn_Endpoint()

vrpn_Endpoint::vrpn_Endpoint ( vrpn_TypeDispatcher * dispatcher,
vrpn_int32 * connectedEndpointCounter )

◆ ~vrpn_Endpoint()

vrpn_Endpoint::~vrpn_Endpoint ( void )
virtual

Definition at line 2809 of file vrpn_Connection.C.

References d_inLog, d_outLog, d_remoteInLogName, d_remoteOutLogName, d_senders, and d_types.

Member Function Documentation

◆ clear_other_senders_and_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(), vrpn_Connection::handle_disconnect_message(), and mainloop().

◆ clearBuffers()

virtual void vrpn_Endpoint::clearBuffers ( void )
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.

References pack_sender_description(), and pack_type_description().

Here is the call graph for this function:

◆ dispatch()

int vrpn_Endpoint::dispatch ( vrpn_int32 type,
vrpn_int32 sender,
timeval time,
vrpn_uint32 payload_len,
char * bufptr )
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().

Here is the call graph for this function:

◆ doing_okay()

virtual vrpn_bool vrpn_Endpoint::doing_okay ( void ) const
pure virtual

Implemented in vrpn_Endpoint_IP.

References init().

Here is the call graph for this function:

◆ drop_connection()

virtual void vrpn_Endpoint::drop_connection ( void )
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().

◆ finish_new_connection_setup()

virtual int vrpn_Endpoint::finish_new_connection_setup ( void )
pure virtual

Implemented in vrpn_Endpoint_IP.

◆ getConnection()

vrpn_Connection * vrpn_Endpoint::getConnection ( )
inline

Definition at line 378 of file vrpn_Connection.h.

References d_parent.

◆ handle_sender_message()

int vrpn_Endpoint::handle_sender_message ( void * userdata,
vrpn_HANDLERPARAM p )
static

◆ handle_type_message()

int vrpn_Endpoint::handle_type_message ( void * userdata,
vrpn_HANDLERPARAM p )
static

◆ init()

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 doing_okay(), and vrpn_Endpoint().

◆ local_sender_id()

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().

◆ local_type_id()

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().

◆ mainloop()

virtual int vrpn_Endpoint::mainloop ( timeval * timeout)
pure virtual

Implemented in vrpn_Endpoint_IP.

References clear_other_senders_and_types(), newLocalSender(), newLocalType(), newRemoteSender(), and newRemoteType().

Here is the call graph for this function:

◆ marshall_message()

int vrpn_Endpoint::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 seqNo )
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().

◆ newLocalSender()

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.

Referenced by mainloop().

◆ newLocalType()

int vrpn_Endpoint::newLocalType ( const char * name,
vrpn_int32 which )

Definition at line 3214 of file vrpn_Connection.C.

References d_types.

Referenced by mainloop().

◆ newRemoteSender()

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(), and mainloop().

◆ newRemoteType()

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(), and mainloop().

◆ openLogs()

int vrpn_Endpoint::openLogs ( void )

Definition at line 4521 of file vrpn_Connection.C.

References d_inLog, and d_outLog.

◆ pack_log_description()

int vrpn_Endpoint::pack_log_description ( void )

◆ pack_message()

virtual int vrpn_Endpoint::pack_message ( vrpn_uint32 len,
struct timeval time,
vrpn_int32 type,
vrpn_int32 sender,
const char * buffer,
vrpn_uint32 class_of_service )
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().

◆ pack_sender_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 clearBuffers(), and vrpn_Endpoint_IP::finish_new_connection_setup().

Here is the call graph for this function:

◆ pack_type_description()

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 clearBuffers(), and vrpn_Endpoint_IP::finish_new_connection_setup().

Here is the call graph for this function:

◆ poll_for_cookie()

virtual void vrpn_Endpoint::poll_for_cookie ( const timeval * timeout = NULL)
pure virtual

Implemented in vrpn_Endpoint_IP.

◆ send_pending_reports()

virtual int vrpn_Endpoint::send_pending_reports ( void )
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.

References pack_log_description().

Referenced by tryToMarshall().

Here is the call graph for this function:

◆ setConnection()

◆ setLogNames()

void vrpn_Endpoint::setLogNames ( const char * inName,
const char * outName )

Definition at line 4511 of file vrpn_Connection.C.

References d_inLog, and d_outLog.

Referenced by vrpn_Connection::handle_log_message().

◆ setup_new_connection()

virtual int vrpn_Endpoint::setup_new_connection ( void )
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().

◆ tryToMarshall()

int vrpn_Endpoint::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 )
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().

Here is the call graph for this function:

Member Data Documentation

◆ d_connectionCounter

vrpn_int32* vrpn_Endpoint::d_connectionCounter
protected

◆ d_dispatcher

◆ d_inLog

◆ d_outLog

◆ d_parent

◆ d_remoteInLogName

char* vrpn_Endpoint::d_remoteInLogName

◆ d_remoteLogMode

long vrpn_Endpoint::d_remoteLogMode

Mode to put the remote logging in.

Todo
XXX These should be protected; making them so will lead to making the code split the functions between Endpoint and Connection protected:

Definition at line 343 of file vrpn_Connection.h.

Referenced by pack_log_description(), vrpn_Endpoint_IP::setup_new_connection(), vrpn_Connection::vrpn_Connection(), vrpn_Connection::vrpn_Connection(), and vrpn_Endpoint().

◆ d_remoteOutLogName

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(), vrpn_Endpoint(), and ~vrpn_Endpoint().

◆ d_senders

◆ d_types

◆ rhostname

char vrpn_Endpoint::rhostname[150]

Definition at line 350 of file vrpn_Connection.h.

Referenced by vrpn_Connection_IP::handle_UDP_message().

◆ status


The documentation for this class was generated from the following files: