public static enum MatsSocketServer.MatsSocketCloseCodes extends java.lang.Enum<MatsSocketServer.MatsSocketCloseCodes> implements javax.websocket.CloseReason.CloseCode
does..!
Enum Constant and Description |
---|
CLOSE_SESSION
4000: Both from Server side and Client/Browser side, client should REJECT all outstanding:
From Client/Browser: Used when the client closes WebSocket "on purpose", wanting to close the session -
typically when the user explicitly logs out, or navigates away from web page.
|
DISCONNECT
4003: From Server side: Currently used in the specific situation where a MatsSocket client connects with the
same MatsSocketSessionId as an existing open WebSocket connection.
|
GOING_AWAY
Standard code 1001 - From Client/Browser side, client should have REJECTed all outstanding: Synonym for
CLOSE_SESSION , as the WebSocket documentation states "indicates that an endpoint is "going away",
such as a server going down or a browser having navigated away from a page.", the latter point
being pretty much exactly correct wrt. |
MATS_SOCKET_PROTOCOL_ERROR
4004: From Server side: Client should REJECT all outstanding and "crash"/reboot application: Used when the
client does not speak the MatsSocket protocol correctly.
|
RECONNECT
4002: Both from Server side and from Client/Browser side: REISSUE all outstanding upon reconnect:
From Client: The client just fancied a little break (just as if lost connection in a tunnel), used from
integration tests.
From Server: We ask that the client reconnects.
|
SERVICE_RESTART
Standard code 1012 - From Server side, Client should REISSUE all outstanding upon reconnect: used when
MatsSocketServer.stop(int) is invoked. |
SESSION_LOST
4001: From Server side, Client should REJECT all outstanding and "crash"/reboot application: A
HELLO:RECONNECT was attempted, but the session was gone.
|
UNEXPECTED_CONDITION
Standard code 1011 - From Server side, Client should REJECT all outstanding and "crash"/reboot application.
|
VIOLATED_POLICY
Standard code 1008 - From Server side, Client should REJECT all outstanding and "crash"/reboot application:
used when we cannot authenticate.
|
Modifier and Type | Method and Description |
---|---|
static javax.websocket.CloseReason.CloseCode |
getCloseCode(int code) |
int |
getCode() |
static MatsSocketServer.MatsSocketCloseCodes |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static MatsSocketServer.MatsSocketCloseCodes[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final MatsSocketServer.MatsSocketCloseCodes VIOLATED_POLICY
public static final MatsSocketServer.MatsSocketCloseCodes UNEXPECTED_CONDITION
public static final MatsSocketServer.MatsSocketCloseCodes SERVICE_RESTART
MatsSocketServer.stop(int)
is invoked. Please reconnect.public static final MatsSocketServer.MatsSocketCloseCodes GOING_AWAY
CLOSE_SESSION
, as the WebSocket documentation states "indicates that an endpoint is "going away",
such as a server going down or a browser having navigated away from a page.", the latter point
being pretty much exactly correct wrt. when to close a session. So, if a browser decides to use this code
when the user navigates away and the client MatsSocket library or employing application does not catch it,
we'd want to catch this as a Close Session. Notice that I've not experienced a browser that actually utilizes
this close code yet, though!
Notice that if a close with this close code is initiated from the Server-side, this should NOT be
considered a CLOSE_SESSION by neither the client nor the server! At least Jetty's implementation of JSR
356 WebSocket API for Java sends GOING_AWAY upon socket close due to timeout. Since a timeout can
happen if we loose connection and thus can't convey PINGs, the MatsSocketServer must not interpret Jetty's
timeout-close as Close Session. Likewise, if the client just experienced massive lag on the connection, and
thus didn't get the PING over to the server in a timely fashion, but then suddenly gets Jetty's timeout close
with GOING_AWAY, this should not be interpreted by the client as the server wants to close the
MatsSocketSession.public static final MatsSocketServer.MatsSocketCloseCodes CLOSE_SESSION
MatsSocketServer.closeSession(String, String)
was invoked, and the WebSocket to that
client was still open, so we close it.public static final MatsSocketServer.MatsSocketCloseCodes SESSION_LOST
public static final MatsSocketServer.MatsSocketCloseCodes RECONNECT
public static final MatsSocketServer.MatsSocketCloseCodes DISCONNECT
public static final MatsSocketServer.MatsSocketCloseCodes MATS_SOCKET_PROTOCOL_ERROR
public static MatsSocketServer.MatsSocketCloseCodes[] values()
for (MatsSocketServer.MatsSocketCloseCodes c : MatsSocketServer.MatsSocketCloseCodes.values()) System.out.println(c);
public static MatsSocketServer.MatsSocketCloseCodes valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic int getCode()
getCode
in interface javax.websocket.CloseReason.CloseCode
public static javax.websocket.CloseReason.CloseCode getCloseCode(int code)
code
- the code to get a CloseCode instance of.MatsSocketServer.MatsSocketCloseCodes
, or a standard CloseReason.CloseCodes
, or a newly created object
containing the unknown close code with a toString() returning "UNKNOWN(code)".