Java Code Examples for org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator#tryCloseWithError()

The following examples show how to use org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator#tryCloseWithError() . 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: StandardWebSocketHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void handleBinaryMessage(javax.websocket.Session session, ByteBuffer payload, boolean isLast) {
	BinaryMessage binaryMessage = new BinaryMessage(payload, isLast);
	try {
		this.handler.handleMessage(this.wsSession, binaryMessage);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 2
Source File: StandardWebSocketHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void onError(javax.websocket.Session session, Throwable exception) {
	try {
		this.handler.handleTransportError(this.wsSession, exception);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 3
Source File: StandardWebSocketHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void handleTextMessage(javax.websocket.Session session, String payload, boolean isLast) {
	TextMessage textMessage = new TextMessage(payload, isLast);
	try {
		this.handler.handleMessage(this.wsSession, textMessage);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 4
Source File: JettyWebSocketHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@OnWebSocketMessage
public void onWebSocketBinary(byte[] payload, int offset, int length) {
	BinaryMessage message = new BinaryMessage(payload, offset, length, true);
	try {
		this.webSocketHandler.handleMessage(this.wsSession, message);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 5
Source File: JettyWebSocketHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@OnWebSocketConnect
public void onWebSocketConnect(Session session) {
	try {
		this.wsSession.initializeNativeSession(session);
		this.webSocketHandler.afterConnectionEstablished(this.wsSession);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 6
Source File: JettyWebSocketHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
@OnWebSocketMessage
public void onWebSocketBinary(byte[] payload, int offset, int length) {
	BinaryMessage message = new BinaryMessage(payload, offset, length, true);
	try {
		this.webSocketHandler.handleMessage(this.wsSession, message);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 7
Source File: JettyWebSocketHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
@OnWebSocketMessage
public void onWebSocketText(String payload) {
	TextMessage message = new TextMessage(payload);
	try {
		this.webSocketHandler.handleMessage(this.wsSession, message);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 8
Source File: JettyWebSocketHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
@OnWebSocketConnect
public void onWebSocketConnect(Session session) {
	try {
		this.wsSession.initializeNativeSession(session);
		this.webSocketHandler.afterConnectionEstablished(this.wsSession);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 9
Source File: StandardWebSocketHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void onError(javax.websocket.Session session, Throwable exception) {
	try {
		this.handler.handleTransportError(this.wsSession, exception);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 10
Source File: StandardWebSocketHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void handlePongMessage(javax.websocket.Session session, ByteBuffer payload) {
	PongMessage pongMessage = new PongMessage(payload);
	try {
		this.handler.handleMessage(this.wsSession, pongMessage);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 11
Source File: StandardWebSocketHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void handleTextMessage(javax.websocket.Session session, String payload, boolean isLast) {
	TextMessage textMessage = new TextMessage(payload, isLast);
	try {
		this.handler.handleMessage(this.wsSession, textMessage);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 12
Source File: StandardWebSocketHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void handleTextMessage(javax.websocket.Session session, String payload, boolean isLast) {
	TextMessage textMessage = new TextMessage(payload, isLast);
	try {
		this.handler.handleMessage(this.wsSession, textMessage);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 13
Source File: JettyWebSocketHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@OnWebSocketError
public void onWebSocketError(Throwable cause) {
	try {
		this.webSocketHandler.handleTransportError(this.wsSession, cause);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 14
Source File: JettyWebSocketHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@OnWebSocketFrame
public void onWebSocketFrame(Frame frame) {
	if (OpCode.PONG == frame.getOpCode()) {
		ByteBuffer payload = frame.getPayload() != null ? frame.getPayload() : EMPTY_PAYLOAD;
		PongMessage message = new PongMessage(payload);
		try {
			this.webSocketHandler.handleMessage(this.wsSession, message);
		}
		catch (Throwable ex) {
			ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
		}
	}
}
 
Example 15
Source File: JettyWebSocketHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@OnWebSocketMessage
public void onWebSocketBinary(byte[] payload, int offset, int length) {
	BinaryMessage message = new BinaryMessage(payload, offset, length, true);
	try {
		this.webSocketHandler.handleMessage(this.wsSession, message);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 16
Source File: JettyWebSocketHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@OnWebSocketMessage
public void onWebSocketText(String payload) {
	TextMessage message = new TextMessage(payload);
	try {
		this.webSocketHandler.handleMessage(this.wsSession, message);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 17
Source File: StandardWebSocketHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void handlePongMessage(javax.websocket.Session session, ByteBuffer payload) {
	PongMessage pongMessage = new PongMessage(payload);
	try {
		this.handler.handleMessage(this.wsSession, pongMessage);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 18
Source File: JettyWebSocketHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@OnWebSocketFrame
public void onWebSocketFrame(Frame frame) {
	if (OpCode.PONG == frame.getOpCode()) {
		ByteBuffer payload = frame.getPayload() != null ? frame.getPayload() : EMPTY_PAYLOAD;
		PongMessage message = new PongMessage(payload);
		try {
			this.webSocketHandler.handleMessage(this.wsSession, message);
		}
		catch (Throwable ex) {
			ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
		}
	}
}
 
Example 19
Source File: StandardWebSocketHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void handlePongMessage(javax.websocket.Session session, ByteBuffer payload) {
	PongMessage pongMessage = new PongMessage(payload);
	try {
		this.handler.handleMessage(this.wsSession, pongMessage);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}
 
Example 20
Source File: StandardWebSocketHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void handleBinaryMessage(javax.websocket.Session session, ByteBuffer payload, boolean isLast) {
	BinaryMessage binaryMessage = new BinaryMessage(payload, isLast);
	try {
		this.handler.handleMessage(this.wsSession, binaryMessage);
	}
	catch (Throwable ex) {
		ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger);
	}
}