402154 - WebSocket / Session.setIdleTimeout(ms) should support in-place idle timeout changes
+ Made WebSocketSession delegate idle timeouts to LogicalConnection, that way the EndPoint or Mux can manage the idle timeout accordingly.
This commit is contained in:
parent
e6fed09129
commit
9e78529a17
|
@ -73,6 +73,12 @@ public interface LogicalConnection extends OutgoingFrames, SuspendToken
|
|||
*/
|
||||
InetSocketAddress getLocalAddress();
|
||||
|
||||
/**
|
||||
* Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)
|
||||
* @return the idle timeout in milliseconds
|
||||
*/
|
||||
long getMaxIdleTimeout();
|
||||
|
||||
/**
|
||||
* The policy that the connection is running under.
|
||||
* @return the policy for the connection
|
||||
|
@ -109,6 +115,14 @@ public interface LogicalConnection extends OutgoingFrames, SuspendToken
|
|||
*/
|
||||
boolean isReading();
|
||||
|
||||
/**
|
||||
* Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)
|
||||
*
|
||||
* @param ms
|
||||
* the number of milliseconds of idle timeout
|
||||
*/
|
||||
void setMaxIdleTimeout(long ms);
|
||||
|
||||
/**
|
||||
* Set where the connection should send the incoming frames to.
|
||||
* <p>
|
||||
|
|
|
@ -59,7 +59,6 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
|
|||
private ExtensionFactory extensionFactory;
|
||||
private long maximumMessageSize;
|
||||
private String protocolVersion;
|
||||
private long timeout;
|
||||
private Map<String, String[]> parameterMap = new HashMap<>();
|
||||
private WebSocketRemoteEndpoint remote;
|
||||
private IncomingFrames incomingHandler;
|
||||
|
@ -165,12 +164,12 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
|
|||
}
|
||||
|
||||
/**
|
||||
* The idle timeout in seconds
|
||||
* The idle timeout in milliseconds
|
||||
*/
|
||||
@Override
|
||||
public long getIdleTimeout()
|
||||
{
|
||||
return timeout;
|
||||
return connection.getMaxIdleTimeout();
|
||||
}
|
||||
|
||||
@ManagedAttribute(readonly = true)
|
||||
|
@ -320,12 +319,12 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the timeout in seconds
|
||||
* Set the timeout in milliseconds
|
||||
*/
|
||||
@Override
|
||||
public void setIdleTimeout(long seconds)
|
||||
public void setIdleTimeout(long ms)
|
||||
{
|
||||
this.timeout = seconds;
|
||||
connection.setMaxIdleTimeout(ms);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -111,6 +111,13 @@ public class MuxChannel implements LogicalConnection, IncomingFrames, SuspendTok
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxIdleTimeout()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketPolicy getPolicy()
|
||||
{
|
||||
|
@ -205,6 +212,13 @@ public class MuxChannel implements LogicalConnection, IncomingFrames, SuspendTok
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxIdleTimeout(long ms)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextIncomingFrames(IncomingFrames incoming)
|
||||
{
|
||||
|
|
|
@ -347,6 +347,12 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
return ioState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxIdleTimeout()
|
||||
{
|
||||
return getEndPoint().getIdleTimeout();
|
||||
}
|
||||
|
||||
public Parser getParser()
|
||||
{
|
||||
return parser;
|
||||
|
@ -568,6 +574,12 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
super.setInputBufferSize(inputBufferSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxIdleTimeout(long ms)
|
||||
{
|
||||
getEndPoint().setIdleTimeout(ms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSession(WebSocketSession session)
|
||||
{
|
||||
|
|
|
@ -91,6 +91,13 @@ public class LocalWebSocketConnection implements LogicalConnection, IncomingFram
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxIdleTimeout()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketPolicy getPolicy()
|
||||
{
|
||||
|
@ -148,6 +155,13 @@ public class LocalWebSocketConnection implements LogicalConnection, IncomingFram
|
|||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxIdleTimeout(long ms)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextIncomingFrames(IncomingFrames incoming)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue