vrpn  07.33
Virtual Reality Peripheral Network
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. 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_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. 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_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 200 of file vrpn_Connection.h.

Constructor & Destructor Documentation

◆ vrpn_Endpoint()

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

Definition at line 2634 of file vrpn_Connection.C.

References init().

Here is the call graph for this function:

◆ ~vrpn_Endpoint()

vrpn_Endpoint::~vrpn_Endpoint ( void  )
virtual

Definition at line 2677 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 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().

◆ 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.

◆ dispatch()

int vrpn_Endpoint::dispatch ( vrpn_int32  type,
vrpn_int32  sender,
timeval  time,
vrpn_uint32  payload_len,
char *  bufptr 
)
protectedvirtual

Definition at line 4168 of file vrpn_Connection.C.

References d_dispatcher, local_sender_id(), and local_type_id().

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.

◆ 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 325 of file vrpn_Connection.h.

◆ 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 2774 of file vrpn_Connection.C.

References d_inLog, d_outLog, d_senders, d_types, vrpn_Log, and vrpn_TranslationTable.

Referenced by 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 2760 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 2755 of file vrpn_Connection.C.

References d_types.

Referenced by dispatch(), and vrpn_File_Connection::playone_to_filetime().

◆ mainloop()

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

Implemented in vrpn_Endpoint_IP.

Referenced by vrpn_Connection_IP::mainloop().

◆ 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 4234 of file vrpn_Connection.C.

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 3032 of file vrpn_Connection.C.

References d_senders.

Referenced by vrpn_Connection::register_sender().

◆ newLocalType()

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

Definition at line 3041 of file vrpn_Connection.C.

References d_types.

Referenced by vrpn_Connection::register_message_type().

◆ newRemoteSender()

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

◆ 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 3047 of file vrpn_Connection.C.

References d_types.

Referenced by handle_type_message().

◆ openLogs()

int vrpn_Endpoint::openLogs ( void  )

Definition at line 4374 of file vrpn_Connection.C.

References d_inLog, d_outLog, and vrpn_Log::open().

Here is the call graph for this function:

◆ 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 4466 of file vrpn_Connection.C.

References d_dispatcher, pack_message(), vrpn_CONNECTION_RELIABLE, vrpn_CONNECTION_SENDER_DESCRIPTION, and vrpn_gettimeofday.

Referenced by vrpn_Connection::pack_sender_description().

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 4436 of file vrpn_Connection.C.

References d_dispatcher, pack_message(), vrpn_CONNECTION_RELIABLE, vrpn_CONNECTION_TYPE_DESCRIPTION, and vrpn_gettimeofday.

Referenced by vrpn_Connection::pack_type_description().

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.

Referenced by tryToMarshall().

◆ setConnection()

◆ setLogNames()

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

Here is the call graph for this function:

◆ 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 4199 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

Definition at line 356 of file vrpn_Connection.h.

Referenced by vrpn_Endpoint_IP::drop_connection().

◆ d_dispatcher

◆ d_inLog

◆ d_outLog

◆ d_parent

◆ d_remoteInLogName

char* vrpn_Endpoint::d_remoteInLogName

Name of the remote log file.

Definition at line 291 of file vrpn_Connection.h.

Referenced by vrpn_Connection::get_log_names(), pack_log_description(), vrpn_Connection::vrpn_Connection(), and ~vrpn_Endpoint().

◆ 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 290 of file vrpn_Connection.h.

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

◆ 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 292 of file vrpn_Connection.h.

Referenced by vrpn_Connection::get_log_names(), pack_log_description(), vrpn_Connection::vrpn_Connection(), and ~vrpn_Endpoint().

◆ d_senders

vrpn_TranslationTable* vrpn_Endpoint::d_senders
protected

◆ d_types

vrpn_TranslationTable* vrpn_Endpoint::d_types
protected

◆ rhostname

char vrpn_Endpoint::rhostname[150]

Definition at line 297 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: