Skip to content

Commit

Permalink
rework SendBuffer fixing an issue where ClearBuffer() nuked the buffe…
Browse files Browse the repository at this point in the history
…r after playing to the first client
  • Loading branch information
Jim Hull committed Sep 13, 2011
1 parent c13148b commit 793c346
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions Chan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,23 @@ void CChan::SendBuffer(CClient* pClient) {
if (m_pNetwork && m_pNetwork->IsUserAttached()) {
const vector<CString>& vsBuffer = GetBuffer();

// in the event that pClient is NULL, need to send this to all clients for the user
// I'm presuming here that pClient is listed inside vClients thus vClients at this
// point can't be empty.
//
// This loop has to be cycled twice to maintain the existing behavior which is
// 1. OnChanBufferStarting
// 2. OnChanBufferPlayLine
// 3. ClearBuffer() if not keeping the buffer
// 4. OnChanBufferEnding
//
// With the exception of ClearBuffer(), this needs to happen per client, and
// if pClient is not NULL, the loops break after the first iteration.
//
// Rework this if you like ...
if (vsBuffer.size()) {
const vector<CClient*> & vClients = m_pNetwork->GetClients();
for( size_t uClient = 0; uClient < vClients.size(); ++uClient ) {
// in the event that pClient is NULL, need to send this to all clients for the user
// I'm presuming here that pClient is listed inside vClients so thus vClients at this
// point can't be empty. Rework this if you like ...

CClient * pUseClient = ( pClient ? pClient : vClients[uClient] );
bool bSkipStatusMsg = false;
Expand All @@ -564,21 +575,29 @@ void CChan::SendBuffer(CClient* pClient) {
m_pNetwork->PutUser(sLine, pUseClient);
}

if (!KeepBuffer()) {
ClearBuffer();
}
if( pClient )
break;

}

if (!KeepBuffer()) {
ClearBuffer();
}

bSkipStatusMsg = false;
for( size_t uClient = 0; uClient < vClients.size(); ++uClient ) {

CClient * pUseClient = ( pClient ? pClient : vClients[uClient] );
bool bSkipStatusMsg = false;
NETWORKMODULECALL(OnChanBufferEnding(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true);

if (!bSkipStatusMsg) {
m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Playback Complete.", pUseClient);
}

if( pClient )
if( pClient )
break;

}

}
}
}

0 comments on commit 793c346

Please sign in to comment.