RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_ForwarderController.h
1#ifndef VRPN_FORWARDER_CONTROLLER_H
2#define VRPN_FORWARDER_CONTROLLER_H
3
4#include "vrpn_Configure.h" // for VRPN_API, VRPN_CALLBACK
5#include "vrpn_Types.h" // for vrpn_int32
6// vrpn_Forwarder_Controller
7//
8// Tom Hudson, September 1998
9
10// Written to allow remote a client to tell a server to open another port
11// and forward some messages on it to a friend of the client's.
12
13// Any server that wishes to implement this needs only construct a
14// vrpn_Forwarder_Server for each server connection it has open and
15// to call the vrpn_Forwarder_Server mainloop frequently.
16
17// Clients can construct a vrpn_Forwarder_Controller on a connection
18// and call start_remote_forwarding(port) to tell the server to open
19// <port>, then call forward_message_type(port, name) to start forwarding
20// messages of the given name.
21
22// This isn't an ideal solution, because it means clients need access to
23// the names of the message, which they are normally insulated from.
24
25// Some of the fancier options of the Forwarder (renaming services or
26// types, changing class of service) are hidden from the user; this
27// is meant to be a simple interface and simple first implementation.
28
29// New Forwarder_Servers are NOT constructed on connections that a
30// Forwarder_Server opens, so clients that are only listening to a
31// forwarded stream cannot open new forwarders for still other clients to
32// listen to.
33
34class VRPN_API vrpn_ConnectionForwarder;
35class VRPN_API vrpn_Connection;
37
38class VRPN_API vrpn_Forwarder_Brain {
39
40public:
42 virtual ~vrpn_Forwarder_Brain(void);
43
44 // Tell a Forwarder_Server to open a vrpn_Connection on remote_port.
45
46 virtual vrpn_bool start_remote_forwarding(vrpn_int32 remote_port) = 0;
47
48 // Tell a Forwarder_Server to begin forwarding messages of type
49 // message_type from the sender named service_name over remote_port.
50
51 virtual void forward_message_type(vrpn_int32 remote_port,
52 const char *service_name,
53 const char *message_type) = 0;
54
55protected:
56 vrpn_Connection *d_connection;
57
58 vrpn_int32 d_myId;
59
60 vrpn_int32 d_start_forwarding_type;
61 vrpn_int32 d_forward_type;
62
63 static char *encode_start_remote_forwarding(vrpn_int32 *length,
64 vrpn_int32 remote_port);
65 static char *encode_forward_message_type(vrpn_int32 *length,
66 vrpn_int32 remote_port,
67 const char *service_name,
68 const char *message_type);
69
70 static void decode_start_remote_forwarding(const char *buffer,
71 vrpn_int32 *remote_port);
72 static void decode_forward_message_type(const char *buffer,
73 vrpn_int32 *remote_port,
74 char **service_name,
75 char **message_type);
76};
77
78// Server class
79
80// VRPN server builders who want to enable remotely-controlled forwarding in
81// their server need only create a Forwarder_Server on their server Connections
82// and call its mainloop() regularly.
83
86 vrpn_int32 port;
87 vrpn_Connection *connection;
88 vrpn_ConnectionForwarder *forwarder;
89};
90
92
93public:
95 virtual ~vrpn_Forwarder_Server(void);
96
97 virtual void mainloop(void);
98
99 virtual vrpn_bool start_remote_forwarding(vrpn_int32 remote_port);
100
101 virtual void forward_message_type(vrpn_int32 remote_port,
102 const char *service_name,
103 const char *message_type);
104
105protected:
106 vrpn_Forwarder_List *d_myForwarders;
107
108private:
109 static int VRPN_CALLBACK handle_start(void *, vrpn_HANDLERPARAM);
110 static int VRPN_CALLBACK handle_forward(void *, vrpn_HANDLERPARAM);
111};
112
113// Client class
114
115// Construct a Forwarder_Controller on a connection to control a
116// Forwarder_Server on its far end.
117
119
120public:
123
124 virtual vrpn_bool start_remote_forwarding(vrpn_int32 remote_port);
125
126 virtual void forward_message_type(vrpn_int32 remote_port,
127 const char *service_name,
128 const char *message_type);
129};
130
131#endif // VRPN_FORWARDER_CONTROLLER_H
定义 vrpn_Forwarder.h:28
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_ForwarderController.h:38
定义 vrpn_ForwarderController.h:118
定义 vrpn_ForwarderController.h:91
定义 vrpn_ForwarderController.h:84
This structure is what is passed to a vrpn_Connection message callback.
定义 vrpn_Connection.h:41