Making error message on Session.getRemote() more clear about connection state

This commit is contained in:
Joakim Erdfelt 2013-06-14 09:27:18 -07:00
parent 6d75e18661
commit f092eeb94c
1 changed files with 6 additions and 3 deletions

View File

@ -245,11 +245,14 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
@Override
public RemoteEndpoint getRemote()
{
if (!isOpen())
ConnectionState state = connection.getIOState().getConnectionState();
if ((state == ConnectionState.OPEN) || (state == ConnectionState.CONNECTED))
{
throw new WebSocketException("Session has not been opened yet");
return remote;
}
return remote;
throw new WebSocketException("RemoteEndpoint unavailable, current state [" + state + "], expecting [OPEN or CONNECTED]");
}
@Override