});
// Configure the transport with any additional properties or filters. Although the returned transport is not explicitly
// persisted, if it is a filter (e.g., InactivityMonitor) it will be linked to the client's transport as a TransportListener
// and not GC'd until the client's transport is disposed.
Transport transport = answer;
try {
// Preserve the transportOptions for future use by making a copy before applying (they are removed when applied).
HashMap options = new HashMap(transportOptions);
transport = transportFactory.serverConfigure(answer, null, options);
} catch (Exception e) {
IOExceptionSupport.create(e);
}
// Wait for the transport to be connected or disposed.
listener.onAccept(transport);
while (!transport.isConnected() && !transport.isDisposed()) {
try {
Thread.sleep(100);
} catch (InterruptedException ignore) {
}
}
// Ensure that the transport was not prematurely disposed.
if (transport.isDisposed()) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "The session for clientID '" + clientID + "' was prematurely disposed");
LOG.warn("The session for clientID '" + clientID + "' was prematurely disposed");
return null;
}