diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-28 11:16:01 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-08-02 18:00:54 +0200 |
commit | 4311938f7e838c6263b0e5774e611ec213cb02c6 (patch) | |
tree | 2d1ffba0cb321b65165dcd90f9c34b97e4ec005b /tubes/source/conference.cxx | |
parent | 326235584f9dc17c0adf4c02180f45d4c3dc1e64 (diff) |
tubes: impose strict ordering on 1-1 collaboration
- master (the one who started the session) echoes back packets from
slave, who only then, after receiving own commands executes them
Change-Id: I8b5a1d1bae0d665b65fe2ec0121430178728274d
Diffstat (limited to 'tubes/source/conference.cxx')
-rw-r--r-- | tubes/source/conference.cxx | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/tubes/source/conference.cxx b/tubes/source/conference.cxx index bc2dc753f91f..f024685f04d9 100644 --- a/tubes/source/conference.cxx +++ b/tubes/source/conference.cxx @@ -131,7 +131,13 @@ static void TeleConference_MethodCallHandler( SAL_INFO( "tubes", "TeleConference_MethodCallHandler: received packet from sender " << (pSender ? pSender : "(null)") << " with size " << nPacketSize); - pConference->queue( OString( pPacketData, nPacketSize ) ); + OString aPacket( pPacketData, nPacketSize ); + pConference->queue( aPacket ); + // Master needs to send the packet back to impose ordering, + // so the slave can execute his command. + if (pConference->isMaster()) + pConference->sendPacket( aPacket ); + g_dbus_method_invocation_return_value( pInvocation, 0 ); g_variant_unref( ay); @@ -226,12 +232,14 @@ static void TeleConference_TubeAcceptedHandler( } -TeleConference::TeleConference( TeleManager* pManager, TpAccount* pAccount, TpDBusTubeChannel* pChannel, const OString sUuid ) +TeleConference::TeleConference( TeleManager* pManager, TpAccount* pAccount, + TpDBusTubeChannel* pChannel, const OString sUuid, bool bMaster ) : - mpManager( pManager), - mpAccount( NULL), - mpChannel( NULL), - msUuid( sUuid), + mpManager( pManager ), + mpAccount( NULL ), + mpChannel( NULL ), + msUuid( sUuid ), + mbMaster( bMaster ), pImpl( new TeleConferenceImpl() ) { setChannel( pAccount, pChannel ); @@ -431,12 +439,17 @@ bool TeleConference::sendPacket( const OString& rPacket ) G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); - /* FIXME: need to impose an ordering on packets. */ - queue( rPacket ); + // If we started the session, we can execute commands immediately. + if (mbMaster) + queue( rPacket ); return true; } +bool TeleConference::isMaster() const +{ + return mbMaster; +} void TeleConference::queue( const OString &rPacket ) { |