io.undertow.websockets.core.CloseMessage Java Examples
The following examples show how to use
io.undertow.websockets.core.CloseMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebSocketMessageListener.java From core-ng-project with Apache License 2.0 | 6 votes |
@Override protected void onCloseMessage(CloseMessage message, WebSocketChannel channel) { var wrapper = (ChannelImpl) channel.getAttribute(WebSocketHandler.CHANNEL_KEY); ActionLog actionLog = logManager.begin("=== ws close message handling begin ==="); try { actionLog.action(wrapper.action + ":close"); linkContext(channel, wrapper, actionLog); int code = message.getCode(); String reason = message.getReason(); actionLog.context("code", code); logger.debug("[channel] reason={}", reason); actionLog.track("ws", 0, 1, 0); wrapper.handler.listener.onClose(wrapper, code, reason); } catch (Throwable e) { logManager.logError(e); } finally { logManager.end("=== ws close message handling end ==="); } }
Example #2
Source File: Term.java From termd with Apache License 2.0 | 6 votes |
HttpHandler webSocketStatusUpdateHandler() { WebSocketConnectionCallback webSocketConnectionCallback = (exchange, webSocketChannel) -> { Consumer<TaskStatusUpdateEvent> statusUpdateListener = event -> { Map<String, Object> statusUpdate = new HashMap<>(); statusUpdate.put("action", "status-update"); statusUpdate.put("event", event); ObjectMapper objectMapper = new ObjectMapper(); try { String message = objectMapper.writeValueAsString(statusUpdate); WebSockets.sendText(message, webSocketChannel, null); } catch (JsonProcessingException e) { log.error("Cannot write object to JSON", e); String errorMessage = "Cannot write object to JSON: " + e.getMessage(); WebSockets.sendClose(CloseMessage.UNEXPECTED_ERROR, errorMessage, webSocketChannel, null); } }; log.debug("Registering new status update listener {}.", statusUpdateListener); addStatusUpdateListener(statusUpdateListener); webSocketChannel.addCloseTask((task) -> removeStatusUpdateListener(statusUpdateListener)); }; return new WebSocketProtocolHandshakeHandler(webSocketConnectionCallback); }
Example #3
Source File: UndertowWebSocketSession.java From spring-analysis-note with MIT License | 5 votes |
@Override public Mono<Void> close(CloseStatus status) { CloseMessage cm = new CloseMessage(status.getCode(), status.getReason()); if (!getDelegate().isCloseFrameSent()) { WebSockets.sendClose(cm, getDelegate(), null); } return Mono.empty(); }
Example #4
Source File: UndertowWebSocketSession.java From java-technology-stack with MIT License | 5 votes |
@Override public Mono<Void> close(CloseStatus status) { CloseMessage cm = new CloseMessage(status.getCode(), status.getReason()); if (!getDelegate().isCloseFrameSent()) { WebSockets.sendClose(cm, getDelegate(), null); } return Mono.empty(); }
Example #5
Source File: UndertowWebSocketHandlerAdapter.java From spring-analysis-note with MIT License | 4 votes |
@Override protected void onFullCloseMessage(WebSocketChannel channel, BufferedBinaryMessage message) { CloseMessage closeMessage = new CloseMessage(message.getData().getResource()); this.session.handleClose(new CloseStatus(closeMessage.getCode(), closeMessage.getReason())); message.getData().free(); }
Example #6
Source File: UndertowWebSocketHandlerAdapter.java From java-technology-stack with MIT License | 4 votes |
@Override protected void onFullCloseMessage(WebSocketChannel channel, BufferedBinaryMessage message) { CloseMessage closeMessage = new CloseMessage(message.getData().getResource()); this.session.handleClose(new CloseStatus(closeMessage.getCode(), closeMessage.getReason())); message.getData().free(); }
Example #7
Source File: MangooWebSocket.java From mangooio with Apache License 2.0 | 4 votes |
@Override protected void onCloseMessage(CloseMessage closeMessage, WebSocketChannel channel) {}
Example #8
Source File: WebSocketController.java From mangooio with Apache License 2.0 | 4 votes |
@Override protected void onCloseMessage(CloseMessage closeMessage, WebSocketChannel channel) { LOG.info(closeMessage.toString()); }
Example #9
Source File: UndertowWebSocketAdapter.java From pippo with Apache License 2.0 | 4 votes |
@Override protected void onCloseMessage(CloseMessage cm, WebSocketChannel channel) { handler.onClose(context, cm.getCode(), cm.getReason()); }