org.apache.tomcat.websocket.WsSession Java Examples
The following examples show how to use
org.apache.tomcat.websocket.WsSession.
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: WsServerContainer.java From tomcatsrc with Apache License 2.0 | 5 votes |
private void registerAuthenticatedSession(WsSession wsSession, String httpSessionId) { Set<WsSession> wsSessions = authenticatedSessions.get(httpSessionId); if (wsSessions == null) { wsSessions = Collections.newSetFromMap( new ConcurrentHashMap<WsSession,Boolean>()); authenticatedSessions.putIfAbsent(httpSessionId, wsSessions); wsSessions = authenticatedSessions.get(httpSessionId); } wsSessions.add(wsSession); }
Example #2
Source File: WsServerContainer.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public void closeAuthenticatedSession(String httpSessionId) { Set<WsSession> wsSessions = authenticatedSessions.remove(httpSessionId); if (wsSessions != null && !wsSessions.isEmpty()) { for (WsSession wsSession : wsSessions) { try { wsSession.close(AUTHENTICATED_HTTP_SESSION_CLOSED); } catch (IOException e) { // Any IOExceptions during close will have been caught and the // onError method called. } } } }
Example #3
Source File: WsServerContainer.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private void unregisterAuthenticatedSession(WsSession wsSession, String httpSessionId) { Set<WsSession> wsSessions = authenticatedSessions.get(httpSessionId); // wsSessions will be null if the HTTP session has ended if (wsSessions != null) { wsSessions.remove(wsSession); } }
Example #4
Source File: WsServerContainer.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private void registerAuthenticatedSession(WsSession wsSession, String httpSessionId) { Set<WsSession> wsSessions = authenticatedSessions.get(httpSessionId); if (wsSessions == null) { wsSessions = Collections.newSetFromMap( new ConcurrentHashMap<WsSession,Boolean>()); authenticatedSessions.putIfAbsent(httpSessionId, wsSessions); wsSessions = authenticatedSessions.get(httpSessionId); } wsSessions.add(wsSession); }
Example #5
Source File: WsServerContainer.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * * Overridden to make it visible to other classes in this package. */ @Override protected void unregisterSession(Endpoint endpoint, WsSession wsSession) { if (wsSession.getUserPrincipal() != null && wsSession.getHttpSessionId() != null) { unregisterAuthenticatedSession(wsSession, wsSession.getHttpSessionId()); } super.unregisterSession(endpoint, wsSession); }
Example #6
Source File: WsServerContainer.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * * Overridden to make it visible to other classes in this package. */ @Override protected void registerSession(Endpoint endpoint, WsSession wsSession) { super.registerSession(endpoint, wsSession); if (wsSession.isOpen() && wsSession.getUserPrincipal() != null && wsSession.getHttpSessionId() != null) { registerAuthenticatedSession(wsSession, wsSession.getHttpSessionId()); } }
Example #7
Source File: PojoMessageHandlerPartialBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public final void onMessage(T message, boolean last) { if (params.length == 1 && params[0] instanceof DecodeException) { ((WsSession) session).getLocal().onError(session, (DecodeException) params[0]); return; } Object[] parameters = params.clone(); if (indexBoolean != -1) { parameters[indexBoolean] = Boolean.valueOf(last); } if (indexSession != -1) { parameters[indexSession] = session; } if (convert) { parameters[indexPayload] = ((ByteBuffer) message).array(); } else { parameters[indexPayload] = message; } Object result = null; try { result = method.invoke(pojo, parameters); } catch (IllegalAccessException | InvocationTargetException e) { handlePojoMethodException(e); } processResult(result); }
Example #8
Source File: WsServerContainer.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * * Overridden to make it visible to other classes in this package. */ @Override protected void registerSession(Endpoint endpoint, WsSession wsSession) { super.registerSession(endpoint, wsSession); if (wsSession.isOpen() && wsSession.getUserPrincipal() != null && wsSession.getHttpSessionId() != null) { registerAuthenticatedSession(wsSession, wsSession.getHttpSessionId()); } }
Example #9
Source File: WsServerContainer.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * * Overridden to make it visible to other classes in this package. */ @Override protected void unregisterSession(Endpoint endpoint, WsSession wsSession) { if (wsSession.getUserPrincipal() != null && wsSession.getHttpSessionId() != null) { unregisterAuthenticatedSession(wsSession, wsSession.getHttpSessionId()); } super.unregisterSession(endpoint, wsSession); }
Example #10
Source File: WsServerContainer.java From tomcatsrc with Apache License 2.0 | 5 votes |
private void unregisterAuthenticatedSession(WsSession wsSession, String httpSessionId) { Set<WsSession> wsSessions = authenticatedSessions.get(httpSessionId); // wsSessions will be null if the HTTP session has ended if (wsSessions != null) { wsSessions.remove(wsSession); } }
Example #11
Source File: WsServerContainer.java From Tomcat8-Source-Read with MIT License | 5 votes |
public void closeAuthenticatedSession(String httpSessionId) { Set<WsSession> wsSessions = authenticatedSessions.remove(httpSessionId); if (wsSessions != null && !wsSessions.isEmpty()) { for (WsSession wsSession : wsSessions) { try { wsSession.close(AUTHENTICATED_HTTP_SESSION_CLOSED); } catch (IOException e) { // Any IOExceptions during close will have been caught and the // onError method called. } } } }
Example #12
Source File: WsServerContainer.java From Tomcat8-Source-Read with MIT License | 5 votes |
private void unregisterAuthenticatedSession(WsSession wsSession, String httpSessionId) { Set<WsSession> wsSessions = authenticatedSessions.get(httpSessionId); // wsSessions will be null if the HTTP session has ended if (wsSessions != null) { wsSessions.remove(wsSession); } }
Example #13
Source File: WsServerContainer.java From Tomcat8-Source-Read with MIT License | 5 votes |
private void registerAuthenticatedSession(WsSession wsSession, String httpSessionId) { Set<WsSession> wsSessions = authenticatedSessions.get(httpSessionId); if (wsSessions == null) { wsSessions = Collections.newSetFromMap( new ConcurrentHashMap<WsSession,Boolean>()); authenticatedSessions.putIfAbsent(httpSessionId, wsSessions); wsSessions = authenticatedSessions.get(httpSessionId); } wsSessions.add(wsSession); }
Example #14
Source File: WsServerContainer.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * {@inheritDoc} * * Overridden to make it visible to other classes in this package. */ @Override protected void unregisterSession(Object key, WsSession wsSession) { if (wsSession.getUserPrincipal() != null && wsSession.getHttpSessionId() != null) { unregisterAuthenticatedSession(wsSession, wsSession.getHttpSessionId()); } super.unregisterSession(key, wsSession); }
Example #15
Source File: WsServerContainer.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * {@inheritDoc} * * Overridden to make it visible to other classes in this package. */ @Override protected void registerSession(Object key, WsSession wsSession) { super.registerSession(key, wsSession); if (wsSession.isOpen() && wsSession.getUserPrincipal() != null && wsSession.getHttpSessionId() != null) { registerAuthenticatedSession(wsSession, wsSession.getHttpSessionId()); } }
Example #16
Source File: WsServerContainer.java From tomcatsrc with Apache License 2.0 | 5 votes |
public void closeAuthenticatedSession(String httpSessionId) { Set<WsSession> wsSessions = authenticatedSessions.remove(httpSessionId); if (wsSessions != null && !wsSessions.isEmpty()) { for (WsSession wsSession : wsSessions) { try { wsSession.close(AUTHENTICATED_HTTP_SESSION_CLOSED); } catch (IOException e) { // Any IOExceptions during close will have been caught and the // onError method called. } } } }
Example #17
Source File: TomcatWebSocketSession.java From java-technology-stack with MIT License | 4 votes |
@Override protected void resumeReceiving() { if (SUSPENDED.compareAndSet(this, 1, 0)) { ((WsSession) getDelegate()).resume(); } }
Example #18
Source File: WsFrameServer.java From tomcatsrc with Apache License 2.0 | 4 votes |
public WsFrameServer(AbstractServletInputStream sis, WsSession wsSession, Transformation transformation) { super(wsSession, transformation); this.sis = sis; }
Example #19
Source File: WsFrameServer.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
public WsFrameServer(AbstractServletInputStream sis, WsSession wsSession, Transformation transformation) { super(wsSession, transformation); this.sis = sis; }
Example #20
Source File: TomcatWebSocketSession.java From java-technology-stack with MIT License | 4 votes |
@Override protected void suspendReceiving() { if (SUSPENDED.compareAndSet(this, 0, 1)) { ((WsSession) getDelegate()).suspend(); } }
Example #21
Source File: TomcatWebSocketSession.java From spring-analysis-note with MIT License | 4 votes |
@Override protected void resumeReceiving() { if (SUSPENDED.compareAndSet(this, 1, 0)) { ((WsSession) getDelegate()).resume(); } }
Example #22
Source File: TomcatWebSocketSession.java From spring-analysis-note with MIT License | 4 votes |
@Override protected void suspendReceiving() { if (SUSPENDED.compareAndSet(this, 0, 1)) { ((WsSession) getDelegate()).suspend(); } }
Example #23
Source File: WsFrameServer.java From Tomcat8-Source-Read with MIT License | 4 votes |
public WsFrameServer(SocketWrapperBase<?> socketWrapper, WsSession wsSession, Transformation transformation, ClassLoader applicationClassLoader) { super(wsSession, transformation); this.socketWrapper = socketWrapper; this.applicationClassLoader = applicationClassLoader; }
Example #24
Source File: WsHttpUpgradeHandler.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void init(WebConnection connection) { if (ep == null) { throw new IllegalStateException( sm.getString("wsHttpUpgradeHandler.noPreInit")); } String httpSessionId = null; Object session = handshakeRequest.getHttpSession(); if (session != null ) { httpSessionId = ((HttpSession) session).getId(); } // Need to call onOpen using the web application's class loader // Create the frame using the application's class loader so it can pick // up application specific config from the ServerContainerImpl Thread t = Thread.currentThread(); ClassLoader cl = t.getContextClassLoader(); t.setContextClassLoader(applicationClassLoader); try { wsRemoteEndpointServer = new WsRemoteEndpointImplServer(socketWrapper, webSocketContainer); wsSession = new WsSession(ep, wsRemoteEndpointServer, webSocketContainer, handshakeRequest.getRequestURI(), handshakeRequest.getParameterMap(), handshakeRequest.getQueryString(), handshakeRequest.getUserPrincipal(), httpSessionId, negotiatedExtensions, subProtocol, pathParameters, secure, serverEndpointConfig); wsFrame = new WsFrameServer(socketWrapper, wsSession, transformation, applicationClassLoader); // WsFrame adds the necessary final transformations. Copy the // completed transformation chain to the remote end point. wsRemoteEndpointServer.setTransformation(wsFrame.getTransformation()); ep.onOpen(wsSession, serverEndpointConfig); webSocketContainer.registerSession(serverEndpointConfig.getPath(), wsSession); } catch (DeploymentException e) { throw new IllegalArgumentException(e); } finally { t.setContextClassLoader(cl); } }
Example #25
Source File: PojoMessageHandlerWholeBase.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public final void onMessage(T message) { if (params.length == 1 && params[0] instanceof DecodeException) { ((WsSession) session).getLocal().onError(session, (DecodeException) params[0]); return; } // Can this message be decoded? Object payload; try { payload = decode(message); } catch (DecodeException de) { ((WsSession) session).getLocal().onError(session, de); return; } if (payload == null) { // Not decoded. Convert if required. if (convert) { payload = convert(message); } else { payload = message; } } Object[] parameters = params.clone(); if (indexSession != -1) { parameters[indexSession] = session; } parameters[indexPayload] = payload; Object result = null; try { result = method.invoke(pojo, parameters); } catch (IllegalAccessException | InvocationTargetException e) { handlePojoMethodException(e); } processResult(result); }