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 e23bfc82bb
commit d553f9f907
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