Issue #207 - correcting lifecycle of WebSocketSession and EndpointFunctions
This commit is contained in:
parent
34f0007153
commit
0e9841a3cc
|
@ -116,5 +116,6 @@ public abstract class ConnectPromise extends FuturePromise<Session> implements R
|
||||||
public void setSession(WebSocketSession session)
|
public void setSession(WebSocketSession session)
|
||||||
{
|
{
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
this.client.addManaged(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,7 +320,6 @@ public class UpgradeConnection extends AbstractConnection implements Connection.
|
||||||
|
|
||||||
// Wire up Session <-> Connection
|
// Wire up Session <-> Connection
|
||||||
connection.addListener(session);
|
connection.addListener(session);
|
||||||
connectPromise.setSession(session);
|
|
||||||
|
|
||||||
// Initialize / Negotiate Extensions
|
// Initialize / Negotiate Extensions
|
||||||
ExtensionStack extensionStack = new ExtensionStack(connectPromise.getClient().getExtensionFactory());
|
ExtensionStack extensionStack = new ExtensionStack(connectPromise.getClient().getExtensionFactory());
|
||||||
|
@ -338,7 +337,9 @@ public class UpgradeConnection extends AbstractConnection implements Connection.
|
||||||
extensionStack.setNextOutgoing(connection);
|
extensionStack.setNextOutgoing(connection);
|
||||||
|
|
||||||
session.addManaged(extensionStack);
|
session.addManaged(extensionStack);
|
||||||
connectPromise.getClient().addManaged(session);
|
|
||||||
|
// let waiting client know about session
|
||||||
|
connectPromise.setSession(session);
|
||||||
|
|
||||||
// Now swap out the connection
|
// Now swap out the connection
|
||||||
endp.upgrade(connection);
|
endp.upgrade(connection);
|
||||||
|
|
|
@ -174,8 +174,8 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem
|
||||||
LOG.debug("Using RemoteEndpointFactory: {}", remoteEndpointFactory);
|
LOG.debug("Using RemoteEndpointFactory: {}", remoteEndpointFactory);
|
||||||
|
|
||||||
this.endpointFunctions = newEndpointFunctions(this.endpoint);
|
this.endpointFunctions = newEndpointFunctions(this.endpoint);
|
||||||
addBean(this.endpointFunctions);
|
addManaged(this.endpointFunctions);
|
||||||
|
|
||||||
super.doStart();
|
super.doStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,8 @@ public class CommonEndpointFunctions<T extends Session> extends AbstractLifeCycl
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws Exception
|
protected void doStart() throws Exception
|
||||||
{
|
{
|
||||||
super.doStart();
|
|
||||||
discoverEndpointFunctions(this.endpoint);
|
discoverEndpointFunctions(this.endpoint);
|
||||||
|
super.doStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void discoverEndpointFunctions(Object endpoint)
|
protected void discoverEndpointFunctions(Object endpoint)
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.common.function;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.util.component.LifeCycle;
|
||||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||||
import org.eclipse.jetty.websocket.common.CloseInfo;
|
import org.eclipse.jetty.websocket.common.CloseInfo;
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ import org.eclipse.jetty.websocket.common.CloseInfo;
|
||||||
*
|
*
|
||||||
* @param <T> the Session object
|
* @param <T> the Session object
|
||||||
*/
|
*/
|
||||||
public interface EndpointFunctions<T>
|
public interface EndpointFunctions<T> extends LifeCycle
|
||||||
{
|
{
|
||||||
void onOpen(T session);
|
void onOpen(T session);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue