Skip to content

Commit

Permalink
Add HasMessagesToSend to yojimbo's public interface
Browse files Browse the repository at this point in the history
  • Loading branch information
geneotech committed Dec 18, 2018
1 parent 01e0a0b commit 06db090
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
26 changes: 26 additions & 0 deletions yojimbo.cpp
Expand Up @@ -2349,6 +2349,12 @@ namespace yojimbo
return !m_messageSendQueue->IsFull();
}

bool UnreliableUnorderedChannel::HasMessagesToSend() const
{
yojimbo_assert( m_messageSendQueue );
return !m_messageSendQueue->IsEmpty();
}

void UnreliableUnorderedChannel::SendMessage( Message * message, void *context )
{
yojimbo_assert( message );
Expand Down Expand Up @@ -2686,6 +2692,12 @@ namespace yojimbo
return m_channel[channelIndex]->CanSendMessage();
}

bool Connection::HasMessagesToSend( int channelIndex ) const {
yojimbo_assert( channelIndex >= 0 );
yojimbo_assert( channelIndex < m_connectionConfig.numChannels );
return m_channel[channelIndex]->HasMessagesToSend();
}

void Connection::SendMessage( int channelIndex, Message * message, void *context)
{
yojimbo_assert( channelIndex >= 0 );
Expand Down Expand Up @@ -3095,6 +3107,12 @@ namespace yojimbo
return m_connection->CanSendMessage( channelIndex );
}

bool BaseClient::HasMessagesToSend( int channelIndex ) const
{
yojimbo_assert( m_connection );
return m_connection->HasMessagesToSend( channelIndex );
}

void BaseClient::SendMessage( int channelIndex, Message * message )
{
yojimbo_assert( m_connection );
Expand Down Expand Up @@ -3628,6 +3646,14 @@ namespace yojimbo
return m_clientConnection[clientIndex]->CanSendMessage( channelIndex );
}

bool BaseServer::HasMessagesToSend( int clientIndex, int channelIndex ) const
{
yojimbo_assert( clientIndex >= 0 );
yojimbo_assert( clientIndex < m_maxClients );
yojimbo_assert( m_clientConnection[clientIndex] );
return m_clientConnection[clientIndex]->HasMessagesToSend( channelIndex );
}

void BaseServer::SendMessage( int clientIndex, int channelIndex, Message * message )
{
yojimbo_assert( clientIndex >= 0 );
Expand Down
15 changes: 15 additions & 0 deletions yojimbo.h
Expand Up @@ -4120,6 +4120,13 @@ namespace yojimbo

virtual bool CanSendMessage() const = 0;

/**
Are there any messages in the send queue?
@returns True if there is at least one message in the send queue.
*/

virtual bool HasMessagesToSend() const = 0;

/**
Queue a message to be sent across this channel.
@param message The message to be sent.
Expand Down Expand Up @@ -4603,6 +4610,8 @@ namespace yojimbo

bool CanSendMessage() const;

bool HasMessagesToSend() const;

void SendMessage( Message * message, void *context );

Message * ReceiveMessage();
Expand Down Expand Up @@ -4654,6 +4663,8 @@ namespace yojimbo

bool CanSendMessage( int channelIndex ) const;

bool HasMessagesToSend( int channelIndex ) const;

void SendMessage( int channelIndex, Message * message, void *context = 0);

Message * ReceiveMessage( int channelIndex );
Expand Down Expand Up @@ -5237,6 +5248,8 @@ namespace yojimbo

bool CanSendMessage( int clientIndex, int channelIndex ) const;

bool HasMessagesToSend( int clientIndex, int channelIndex ) const;

void SendMessage( int clientIndex, int channelIndex, Message * message );

Message * ReceiveMessage( int clientIndex, int channelIndex );
Expand Down Expand Up @@ -5640,6 +5653,8 @@ namespace yojimbo

bool CanSendMessage( int channelIndex ) const;

bool HasMessagesToSend( int channelIndex ) const;

void SendMessage( int channelIndex, Message * message );

Message * ReceiveMessage( int channelIndex );
Expand Down

0 comments on commit 06db090

Please sign in to comment.