public void SendResponse(Guid client, ServiceResponse response, bool async)
{
try
{
WaitHandle[] handles = new WaitHandle[0];
if (client != Guid.Empty)
{
// Send message directly to specified client.
if (m_remotingServer.IsClientConnected(client))
handles = new[] { m_remotingServer.SendToAsync(client, response) };
}
else
{
// Send message to all of the connected clients.
if (m_remoteCommandClientID == Guid.Empty)
{
lock (m_remoteClients)
{
handles = m_remoteClients.Select(clientInfo => m_remotingServer.SendToAsync(clientInfo.ClientID, response)).ToArray();
}
}
}
if (!async)
WaitHandle.WaitAll(handles);
}
catch (Exception ex)
{
// Log the exception.
LogException(ex);
}
}