/** * This callback will be invoked when the remote endpoint sent a closing frame. * <p> * The execution of this method is synchronized using {@link ProtocolHandler} instance; see TYRUS-385. Prevents * multiple invocations, especially from container/user code. * * @param frame the close frame from the remote endpoint. */ public void onClose(CloseFrame frame) { boolean locked = lock.tryLock(); if (locked) { try { final CloseReason closeReason = frame.getCloseReason(); if (endpointWrapper != null) { endpointWrapper.onClose(this, closeReason); } if (state.compareAndSet(State.CONNECTED, State.CLOSING)) { protocolHandler.close(closeReason.getCloseCode().getCode(), closeReason.getReasonPhrase()); } else { state.set(State.CLOSED); protocolHandler.doClose(); } } finally { lock.unlock(); } } }
/** * This callback will be invoked when the remote endpoint sent a closing frame. * <p> * The execution of this method is synchronized using {@link ProtocolHandler} instance; see TYRUS-385. Prevents * multiple invocations, especially from container/user code. * * @param frame the close frame from the remote endpoint. */ public void onClose(CloseFrame frame) { boolean locked = lock.tryLock(); if (locked) { try { final CloseReason closeReason = frame.getCloseReason(); if (endpointWrapper != null) { endpointWrapper.onClose(this, closeReason); } if (state.compareAndSet(State.CONNECTED, State.CLOSING)) { protocolHandler.close(closeReason.getCloseCode().getCode(), closeReason.getReasonPhrase()); } else { state.set(State.CLOSED); protocolHandler.doClose(); } } finally { lock.unlock(); } } }