Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Determining whether WebSocket.onClose was triggered by client or server

Is there a way to determine whether a call to onClose was triggered by
the client or the server?

I'm implementing a base WebSocket class, and any time a subclass
throws an exception while handling a message, I close the connection
with an error message. When this happens, the onClose method fires.

My base WebSocket is providing an onClientClose method to my
subclasses, so I'd like to know if there's an easy way to determine
whether a call to onClose was triggered by the Javascript client
closing the connection or by the Java/jetty server closing the
connection. Currently, I'm setting a flag before closing the
connection myself, but I've noticed that any error in jetty also
closes the connection and calls onClose.

Thanks in advance,
Brandon


Back to the top