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