void onStatefulMessage(InterHubMessage message) {
if (message instanceof ConnectionEstablished) {
ConnectionEstablished connectionEstablished = (ConnectionEstablished) message;
queued.put(connectionEstablished.getConnection(), connectionEstablished);
} else if (message instanceof ConnectionClosed) {
ConnectionClosed connectionClosed = (ConnectionClosed) message;
queued.remove(connectionClosed.getConnection());
} else if (message instanceof EndOfStream) {
queued.clear();
endOfStream = (EndOfStream) message;
} else {
throw new UnsupportedOperationException(String.format("Received unexpected stateful message: %s", message));