@Override
public void onEvent(CometEvent event) throws IOException {
active = true;
if (event.getType() == CometEvent.WRITE) {
CometWriter writer = (CometWriter) event.attachment();
try {
// Unfortunately Grizzly's CometWriter assumes that the transfer encoding is going to be chunked and that
// only one chunk is going to be written to the response so we have to write to the SocketChanel directly.
// https://grizzly.dev.java.net/issues/show_bug.cgi?id=791