added setWantMessageBundling

This commit is contained in:
Darren Ranalli 2007-12-06 20:59:25 +00:00
parent 859f6904b8
commit 8cae40674b
3 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;