Panda3D
 All Classes Functions Variables Enumerations
cConnectionRepository.I
1 // Filename: cConnectionRepository.I
2 // Created by: drose (17May04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: CConnectionRepository::get_dc_file
18 // Access: Published
19 // Description: Returns the DCFile object associated with this
20 // repository.
21 ////////////////////////////////////////////////////////////////////
24  return _dc_file;
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: CConnectionRepository::has_owner_view
29 // Access: Published
30 // Description: Returns true if this repository can have 'owner'
31 // views of distributed objects.
32 ////////////////////////////////////////////////////////////////////
33 INLINE bool CConnectionRepository::
34 has_owner_view() const {
35  return _has_owner_view;
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: CConnectionRepository::set_handle_c_updates
40 // Access: Published
41 // Description: Set true to specify this repository should process
42 // distributed updates internally in C++ code, or false
43 // if it should return them to Python.
44 ////////////////////////////////////////////////////////////////////
45 INLINE void CConnectionRepository::
46 set_handle_c_updates(bool handle_c_updates) {
47  _handle_c_updates = handle_c_updates;
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: CConnectionRepository::get_handle_c_updates
52 // Access: Published
53 // Description: Returns true if this repository will process
54 // distributed updates internally in C++ code, or false
55 // if it will return them to Python.
56 ////////////////////////////////////////////////////////////////////
57 INLINE bool CConnectionRepository::
59  return _handle_c_updates;
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: CConnectionRepository::set_client_datagram
64 // Access: Published
65 // Description: Sets the client_datagram flag. If this is true,
66 // incoming datagrams are not expected to be prefixed
67 // with the server routing information like message
68 // sender, channel number, etc.; otherwise, these server
69 // fields are parsed and removed from each incoming
70 // datagram.
71 ////////////////////////////////////////////////////////////////////
72 INLINE void CConnectionRepository::
73 set_client_datagram(bool client_datagram) {
74  _client_datagram = client_datagram;
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: CConnectionRepository::get_client_datagram
79 // Access: Published
80 // Description: Returns the client_datagram flag.
81 ////////////////////////////////////////////////////////////////////
82 INLINE bool CConnectionRepository::
84  return _client_datagram;
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: CConnectionRepository::set_handle_datagrams_internally
89 // Access: Published
90 // Description: Sets the handle_datagrams_internally flag. When
91 // true, certain message types can be handled by the C++
92 // code in in this module. When false, all datagrams,
93 // regardless of message type, are passed up to Python
94 // for processing.
95 //
96 // The CMU distributed-object implementation requires
97 // this to be set false.
98 ////////////////////////////////////////////////////////////////////
99 INLINE void CConnectionRepository::
100 set_handle_datagrams_internally(bool handle_datagrams_internally) {
101  _handle_datagrams_internally = handle_datagrams_internally;
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: CConnectionRepository::get_handle_datagrams_internally
106 // Access: Published
107 // Description: Returns the handle_datagrams_internally flag.
108 ////////////////////////////////////////////////////////////////////
109 INLINE bool CConnectionRepository::
111  return _handle_datagrams_internally;
112 }
113 
114 ////////////////////////////////////////////////////////////////////
115 // Function: CConnectionRepository::get_tcp_header_size
116 // Access: Public
117 // Description: Returns the current setting of TCP header size.
118 // See set_tcp_header_size().
119 ////////////////////////////////////////////////////////////////////
120 INLINE int CConnectionRepository::
122  return _tcp_header_size;
123 }
124 
125 #ifdef HAVE_PYTHON
126 ////////////////////////////////////////////////////////////////////
127 // Function: CConnectionRepository::set_python_repository
128 // Access: Published
129 // Description: Records the pointer to the Python class that derives
130 // from CConnectionRepository. This allows the C++
131 // implementation to directly manipulation some python
132 // structures on the repository.
133 ////////////////////////////////////////////////////////////////////
134 INLINE void CConnectionRepository::
135 set_python_repository(PyObject *python_repository) {
136  _python_repository = python_repository;
137 }
138 #endif // HAVE_PYTHON
139 
140 #ifdef HAVE_NET
141 ////////////////////////////////////////////////////////////////////
142 // Function: CConnectionRepository::get_qcm
143 // Access: Published
144 // Description: Returns the QueuedConnectionManager object associated
145 // with the repository.
146 ////////////////////////////////////////////////////////////////////
147 INLINE QueuedConnectionManager &CConnectionRepository::
148 get_qcm() {
149  return _qcm;
150 }
151 #endif // HAVE_NET
152 
153 #ifdef HAVE_NET
154 ////////////////////////////////////////////////////////////////////
155 // Function: CConnectionRepository::get_cw
156 // Access: Published
157 // Description: Returns the ConnectionWriter object associated
158 // with the repository.
159 ////////////////////////////////////////////////////////////////////
160 INLINE ConnectionWriter &CConnectionRepository::
161 get_cw() {
162  return _cw;
163 }
164  INLINE ConnectionWriter &get_cw();
165 #endif // HAVE_NET
166 
167 #ifdef HAVE_NET
168 ////////////////////////////////////////////////////////////////////
169 // Function: CConnectionRepository::get_qcr
170 // Access: Published
171 // Description: Returns the QueuedConnectionReader object associated
172 // with the repository.
173 ////////////////////////////////////////////////////////////////////
174 INLINE QueuedConnectionReader &CConnectionRepository::
175 get_qcr() {
176  return _qcr;
177 }
178  INLINE QueuedConnectionReader &get_qcr();
179 #endif // HAVE_NET
180 
181 #ifdef WANT_NATIVE_NET
182 ////////////////////////////////////////////////////////////////////
183 // Function: CConnectionRepository::get_bdc
184 // Access: Published
185 // Description: Returns the Buffered_DatagramConnection object associated
186 // with the repository.
187 ////////////////////////////////////////////////////////////////////
188 INLINE Buffered_DatagramConnection &CConnectionRepository::
189 get_bdc() {
190  return _bdc;
191 }
192  INLINE Buffered_DatagramConnection &get_bdc();
193 #endif
194 
195 ////////////////////////////////////////////////////////////////////
196 // Function: CConnectionRepository::get_datagram
197 // Access: Published
198 // Description: Fills the datagram object with the datagram most
199 // recently retrieved by check_datagram().
200 ////////////////////////////////////////////////////////////////////
201 INLINE void CConnectionRepository::
203  ReMutexHolder holder(_lock);
204  dg = _dg;
205 }
206 
207 ////////////////////////////////////////////////////////////////////
208 // Function: CConnectionRepository::get_datagram_iterator
209 // Access: Published
210 // Description: Fills the DatagramIterator object with the iterator
211 // for the datagram most recently retrieved by
212 // check_datagram(). This iterator has already read
213 // past the datagram header and the message type, and is
214 // positioned at the beginning of data.
215 ////////////////////////////////////////////////////////////////////
216 INLINE void CConnectionRepository::
218  ReMutexHolder holder(_lock);
219  di = _di;
220 }
221 
222 ////////////////////////////////////////////////////////////////////
223 // Function: CConnectionRepository::get_msg_channel
224 // Access: Published
225 // Description: Returns the channel(s) to which the current message
226 // was sent, according to the datagram headers. This
227 // information is not available to the client.
228 ////////////////////////////////////////////////////////////////////
229 INLINE CHANNEL_TYPE CConnectionRepository::
230 get_msg_channel(int offset) const {
231  ReMutexHolder holder(_lock);
232  nassertr(offset < (int)_msg_channels.size(),0);
233  return _msg_channels[offset];
234 }
235 
236 INLINE int CConnectionRepository::
237 get_msg_channel_count() const {
238  ReMutexHolder holder(_lock);
239  return _msg_channels.size();
240 }
241 
242 ////////////////////////////////////////////////////////////////////
243 // Function: CConnectionRepository::get_msg_sender
244 // Access: Published
245 // Description: Returns the sender ID of the current message,
246 // according to the datagram headers. This information
247 // is not available to the client.
248 ////////////////////////////////////////////////////////////////////
249 INLINE CHANNEL_TYPE CConnectionRepository::
250 get_msg_sender() const {
251  ReMutexHolder holder(_lock);
252  return _msg_sender;
253 }
254 
255 ////////////////////////////////////////////////////////////////////
256 // Function: CConnectionRepository::get_sec_code
257 // Access: Published
258 // Description: Returns the security code associated with the current
259 // message, according to the datagram headers. This
260 // information is not available to the client.
261 ////////////////////////////////////////////////////////////////////
262 //INLINE unsigned char CConnectionRepository::
263 //get_sec_code() const {
264 // return _sec_code;
265 //}
266 
267 ////////////////////////////////////////////////////////////////////
268 // Function: CConnectionRepository::get_msg_type
269 // Access: Published
270 // Description: Returns the type ID of the current message,
271 // according to the datagram headers.
272 ////////////////////////////////////////////////////////////////////
273 INLINE unsigned int CConnectionRepository::
274 get_msg_type() const {
275  ReMutexHolder holder(_lock);
276  return _msg_type;
277 }
278 
279 ////////////////////////////////////////////////////////////////////
280 // Function: CConnectionRepository::get_overflow_event_name
281 // Access: Published
282 // Description: Returns event string that will be thrown if the
283 // datagram reader queue overflows.
284 ////////////////////////////////////////////////////////////////////
285 INLINE const string &CConnectionRepository::
287  return _overflow_event_name;
288 }
289 
290 ////////////////////////////////////////////////////////////////////
291 // Function: CConnectionRepository::is_bundling_messages
292 // Access: Published
293 // Description: Returns true if repository is queueing outgoing messages
294 // into a message bundle
295 ////////////////////////////////////////////////////////////////////
296 INLINE bool CConnectionRepository::
298  ReMutexHolder holder(_lock);
299  return _bundling_msgs > 0;
300 }
301 
302 ////////////////////////////////////////////////////////////////////
303 // Function: CConnectionRepository::set_want_message_bundling
304 // Access: Published
305 // Description: Enable/disable outbound message bundling
306 ////////////////////////////////////////////////////////////////////
307 INLINE void CConnectionRepository::
309  ReMutexHolder holder(_lock);
310  // don't allow enable/disable while bundling
311  nassertv(_bundling_msgs == 0);
312  _want_message_bundling = flag;
313 }
314 
315 ////////////////////////////////////////////////////////////////////
316 // Function: CConnectionRepository::get_want_message_bundling
317 // Access: Published
318 // Description: Returns true if message bundling enabled
319 ////////////////////////////////////////////////////////////////////
320 INLINE bool CConnectionRepository::
322  ReMutexHolder holder(_lock);
323  return _want_message_bundling;
324 }
325 
326 ////////////////////////////////////////////////////////////////////
327 // Function: CConnectionRepository::set_in_quiet_zone
328 // Access: Published
329 // Description: Enables/disables quiet zone mode
330 ////////////////////////////////////////////////////////////////////
331 INLINE void CConnectionRepository::
332 set_in_quiet_zone(bool flag) {
333  ReMutexHolder holder(_lock);
334  _in_quiet_zone = flag;
335 }
336 
337 ////////////////////////////////////////////////////////////////////
338 // Function: CConnectionRepository::get_in_quiet_zone
339 // Access: Published
340 // Description: Returns true if repository is in quiet zone mode
341 ////////////////////////////////////////////////////////////////////
342 INLINE bool CConnectionRepository::
344  ReMutexHolder holder(_lock);
345  return _in_quiet_zone;
346 }
347 
348 ////////////////////////////////////////////////////////////////////
349 // Function: CConnectionRepository::set_simulated_disconnect
350 // Access: Published
351 // Description: Sets the simulated disconnect flag. While this is
352 // true, no datagrams will be retrieved from or sent to
353 // the server. The idea is to simulate a temporary
354 // network outage.
355 ////////////////////////////////////////////////////////////////////
356 INLINE void CConnectionRepository::
357 set_simulated_disconnect(bool simulated_disconnect) {
358  _simulated_disconnect = simulated_disconnect;
359 }
360 
361 ////////////////////////////////////////////////////////////////////
362 // Function: CConnectionRepository::get_simulated_disconnect
363 // Access: Published
364 // Description: Returns the simulated disconnect flag. While this is
365 // true, no datagrams will be retrieved from or sent to
366 // the server. The idea is to simulate a temporary
367 // network outage.
368 ////////////////////////////////////////////////////////////////////
369 INLINE bool CConnectionRepository::
371  return _simulated_disconnect;
372 }
373 
374 ////////////////////////////////////////////////////////////////////
375 // Function: CConnectionRepository::toggle_verbose
376 // Access: Published
377 // Description: Toggles the current setting of the verbose flag.
378 // When true, this describes every message going back
379 // and forth on the wire.
380 ////////////////////////////////////////////////////////////////////
381 INLINE void CConnectionRepository::
383  _verbose = !_verbose;
384 }
385 
386 ////////////////////////////////////////////////////////////////////
387 // Function: CConnectionRepository::set_verbose
388 // Access: Published
389 // Description: Directly sets the verbose flag. When true, this
390 // describes every message going back and forth on the
391 // wire.
392 ////////////////////////////////////////////////////////////////////
393 INLINE void CConnectionRepository::
394 set_verbose(bool verbose) {
395  _verbose = verbose;
396 }
397 
398 ////////////////////////////////////////////////////////////////////
399 // Function: CConnectionRepository::get_verbose
400 // Access: Published
401 // Description: Returns the current setting of the verbose flag.
402 // When true, this describes every message going back
403 // and forth on the wire.
404 ////////////////////////////////////////////////////////////////////
405 INLINE bool CConnectionRepository::
406 get_verbose() const {
407  return _verbose;
408 }
409 
410 ////////////////////////////////////////////////////////////////////
411 // Function: CConnectionRepository::set_time_warning
412 // Access: Published
413 // Description: Directly sets the time_warning field. When non zero, this
414 // describes every message going back and forth on the
415 // wire when the msg handling time is over it
416 ////////////////////////////////////////////////////////////////////
417 INLINE void CConnectionRepository::
418 set_time_warning(float time_warning) {
419  _time_warning = time_warning;
420 }
421 
422 ////////////////////////////////////////////////////////////////////
423 // Function: CConnectionRepository::get_time_warning
424 // Access: Published
425 // Description: Returns the current setting of the time_warning field.
426 ////////////////////////////////////////////////////////////////////
427 INLINE float CConnectionRepository::
429  return _time_warning;
430 }
void set_time_warning(float time_warning)
Directly sets the time_warning field.
DCFile & get_dc_file()
Returns the DCFile object associated with this repository.
This flavor of ConnectionManager will queue up all of the reset-connection messages from the Connecti...
bool get_handle_c_updates() const
Returns true if this repository will process distributed updates internally in C++ code...
unsigned int get_msg_type() const
Returns the security code associated with the current message, according to the datagram headers...
void set_simulated_disconnect(bool simulated_disconnect)
Sets the simulated disconnect flag.
void toggle_verbose()
Toggles the current setting of the verbose flag.
bool get_want_message_bundling() const
Returns true if message bundling enabled.
CHANNEL_TYPE get_msg_channel(int offset=0) const
Returns the channel(s) to which the current message was sent, according to the datagram headers...
bool get_in_quiet_zone() const
Returns true if repository is in quiet zone mode.
void set_verbose(bool verbose)
Directly sets the verbose flag.
bool get_simulated_disconnect() const
Returns the simulated disconnect flag.
Represents the complete list of Distributed Class descriptions as read from a .dc file...
Definition: dcFile.h:34
bool is_bundling_messages() const
Returns true if repository is queueing outgoing messages into a message bundle.
void set_handle_c_updates(bool handle_c_updates)
Set true to specify this repository should process distributed updates internally in C++ code...
void set_handle_datagrams_internally(bool handle_datagrams_internally)
Sets the handle_datagrams_internally flag.
void get_datagram(Datagram &dg)
Fills the datagram object with the datagram most recently retrieved by check_datagram().
This class handles threaded delivery of datagrams to various TCP or UDP sockets.
void get_datagram_iterator(DatagramIterator &di)
Fills the DatagramIterator object with the iterator for the datagram most recently retrieved by check...
Similar to MutexHolder, but for a reentrant mutex.
Definition: reMutexHolder.h:27
bool get_client_datagram() const
Returns the client_datagram flag.
bool get_handle_datagrams_internally() const
Returns the handle_datagrams_internally flag.
CHANNEL_TYPE get_msg_sender() const
Returns the sender ID of the current message, according to the datagram headers.
This flavor of ConnectionReader will read from its sockets and queue up all of the datagrams read for...
void set_client_datagram(bool client_datagram)
Sets the client_datagram flag.
A class to retrieve the individual data elements previously stored in a Datagram. ...
bool has_owner_view() const
Returns true if this repository can have &#39;owner&#39; views of distributed objects.
void set_in_quiet_zone(bool flag)
Enables/disables quiet zone mode.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
bool get_verbose() const
Returns the current setting of the verbose flag.
float get_time_warning() const
Returns the current setting of the time_warning field.
int get_tcp_header_size() const
Returns the current setting of TCP header size.
void set_want_message_bundling(bool flag)
Enable/disable outbound message bundling.
static const string & get_overflow_event_name()
Returns event string that will be thrown if the datagram reader queue overflows.