output = beginWrite(request, response);
// Write the messages first.
for (int i = 0; i < messages.size(); ++i)
{
ServerMessage message = messages.get(i);
if (i > 0)
output.print(",");
writeMessage(response, output, session, message);
}
}
finally
{
// Start the interval timeout after writing the messages
// since they may take time to be written, even in case
// of exceptions to make sure the session can be swept.
if (startInterval && session != null && session.isConnected())
session.startIntervalTimeout(getInterval());
}
// Write the replies, if any.
boolean needsComma = !messages.isEmpty();
for (int i = 0; i < replies.length; ++i)
{
ServerMessage reply = replies[i];
if (reply == null)
continue;
if (needsComma)
output.print(",");
needsComma = true;