From 8cae40674bf35636844e77b7bab8376e2872f768 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Thu, 6 Dec 2007 20:59:25 +0000 Subject: [PATCH] added setWantMessageBundling --- .../src/distributed/cConnectionRepository.I | 22 +++++++++++++++++++ .../src/distributed/cConnectionRepository.cxx | 5 +++-- .../src/distributed/cConnectionRepository.h | 4 ++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/direct/src/distributed/cConnectionRepository.I b/direct/src/distributed/cConnectionRepository.I index 79db81aa06..cc3f4e8903 100644 --- a/direct/src/distributed/cConnectionRepository.I +++ b/direct/src/distributed/cConnectionRepository.I @@ -258,6 +258,28 @@ is_bundling_messages() const { return _bundling_msgs > 0; } +//////////////////////////////////////////////////////////////////// +// Function: CConnectionRepository::set_want_message_bundling +// Access: Published +// Description: Enable/disable outbound message bundling +//////////////////////////////////////////////////////////////////// +INLINE void CConnectionRepository:: +set_want_message_bundling(bool flag) { + // don't allow enable/disable while bundling + nassertv(_bundling_msgs == 0); + _want_message_bundling = flag; +} + +//////////////////////////////////////////////////////////////////// +// Function: CConnectionRepository::get_want_message_bundling +// Access: Published +// Description: Returns true if message bundling enabled +//////////////////////////////////////////////////////////////////// +INLINE bool CConnectionRepository:: +get_want_message_bundling() const { + return _want_message_bundling; +} + //////////////////////////////////////////////////////////////////// // Function: CConnectionRepository::set_simulated_disconnect // Access: Published diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index e791157680..4935fe9952 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -72,6 +72,7 @@ CConnectionRepository(bool has_owner_view) : _msg_type(0), _has_owner_view(has_owner_view), _handle_c_updates(true), + _want_message_bundling(true), _bundling_msgs(0) { #if defined(HAVE_NET) && defined(SIMULATE_NETWORK_DELAY) @@ -392,7 +393,7 @@ send_datagram(const Datagram &dg) { describe_message(nout, "SEND", dg); } - if (is_bundling_messages()) { + if (is_bundling_messages() && get_want_message_bundling()) { bundle_msg(dg); return false; } @@ -466,7 +467,7 @@ send_message_bundle(unsigned int channel, unsigned int sender_channel) { } // if _bundling_msgs ref count is zero, send the bundle out - if (_bundling_msgs == 0) { + if (_bundling_msgs == 0 && get_want_message_bundling()) { Datagram dg; // add server header (see PyDatagram.addServerHeader) dg.add_int8(1); diff --git a/direct/src/distributed/cConnectionRepository.h b/direct/src/distributed/cConnectionRepository.h index be6dd83dc1..7609841dad 100644 --- a/direct/src/distributed/cConnectionRepository.h +++ b/direct/src/distributed/cConnectionRepository.h @@ -123,6 +123,9 @@ PUBLISHED: bool send_datagram(const Datagram &dg); + INLINE void set_want_message_bundling(bool flag); + INLINE bool get_want_message_bundling() const; + void start_message_bundle(); INLINE bool is_bundling_messages() const; void send_message_bundle(unsigned int channel, unsigned int sender_channel); @@ -193,6 +196,7 @@ private: static const string _overflow_event_name; + bool _want_message_bundling; unsigned int _bundling_msgs; typedef std::vector< const string > BundledMsgVector; BundledMsgVector _bundle_msgs;