org.springframework.web.socket.adapter.NativeWebSocketSession Java Examples

The following examples show how to use org.springframework.web.socket.adapter.NativeWebSocketSession. 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: NodeSession.java    From java-trader with Apache License 2.0 6 votes vote down vote up
public void close() {
    if ( nodeMgmtService==null ) {
        return;
    }
    NodeMgmtServiceImpl svc0 = nodeMgmtService;
    nodeMgmtService = null;

    svc0.onSessionClosed(this);
    wsSession.getAttributes().remove(ATTR_SESSION);
    //TPDP close Jetty webssocket session
    try {
        wsSession.close();
    }catch(Throwable t) {}
    if ( wsSession instanceof NativeWebSocketSession) {
        Object nativeSession = ((NativeWebSocketSession)wsSession).getNativeSession();
        if ( nativeSession!=null && nativeSession instanceof org.eclipse.jetty.websocket.api.Session){
            org.eclipse.jetty.websocket.api.Session jettySession = (org.eclipse.jetty.websocket.api.Session)nativeSession;
            try {
                jettySession.disconnect();
            } catch (Throwable e) {}
        }
    }
    wsSession = null;
    setState(SessionState.Closed);
}
 
Example #2
Source File: WebSocketServerSockJsSession.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public Object getNativeSession() {
	if ((this.webSocketSession != null) && (this.webSocketSession instanceof NativeWebSocketSession)) {
		return ((NativeWebSocketSession) this.webSocketSession).getNativeSession();
	}
	return null;
}
 
Example #3
Source File: WebSocketServerSockJsSession.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public <T> T getNativeSession(Class<T> requiredType) {
	if ((this.webSocketSession != null) && (this.webSocketSession instanceof NativeWebSocketSession)) {
		return ((NativeWebSocketSession) this.webSocketSession).getNativeSession(requiredType);
	}
	return null;
}
 
Example #4
Source File: WebSocketServerSockJsSession.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public Object getNativeSession() {
	Assert.state(this.webSocketSession != null, "WebSocketSession not yet initialized");
	return (this.webSocketSession instanceof NativeWebSocketSession ?
			((NativeWebSocketSession) this.webSocketSession).getNativeSession() : this.webSocketSession);
}
 
Example #5
Source File: WebSocketServerSockJsSession.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@Nullable
public <T> T getNativeSession(@Nullable Class<T> requiredType) {
	return (this.webSocketSession instanceof NativeWebSocketSession ?
			((NativeWebSocketSession) this.webSocketSession).getNativeSession(requiredType) : null);
}
 
Example #6
Source File: WebSocketServerSockJsSession.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public Object getNativeSession() {
	Assert.state(this.webSocketSession != null, "WebSocketSession not yet initialized");
	return (this.webSocketSession instanceof NativeWebSocketSession ?
			((NativeWebSocketSession) this.webSocketSession).getNativeSession() : this.webSocketSession);
}
 
Example #7
Source File: WebSocketServerSockJsSession.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@Nullable
public <T> T getNativeSession(@Nullable Class<T> requiredType) {
	return (this.webSocketSession instanceof NativeWebSocketSession ?
			((NativeWebSocketSession) this.webSocketSession).getNativeSession(requiredType) : null);
}