org.eclipse.jetty.io.AsyncEndPoint Java Examples
The following examples show how to use
org.eclipse.jetty.io.AsyncEndPoint.
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: WebSocketClientFactory.java From IoTgo_Android_App with MIT License | 6 votes |
@Override protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, final SelectionKey key) throws IOException { WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)key.attachment(); int maxIdleTime = holder.getMaxIdleTime(); if (maxIdleTime < 0) maxIdleTime = (int)getMaxIdleTime(); SelectChannelEndPoint result = new SelectChannelEndPoint(channel, selectSet, key, maxIdleTime); AsyncEndPoint endPoint = result; // Detect if it is SSL, and wrap the connection if so if ("wss".equals(holder.getURI().getScheme())) { SSLEngine sslEngine = newSslEngine(channel); SslConnection sslConnection = new SslConnection(sslEngine, endPoint); endPoint.setConnection(sslConnection); endPoint = sslConnection.getSslEndPoint(); } AsyncConnection connection = selectSet.getManager().newConnection(channel, endPoint, holder); endPoint.setConnection(connection); return result; }
Example #2
Source File: WebSocketClientFactory.java From WebSocket-for-Android with Apache License 2.0 | 6 votes |
@Override protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, final SelectionKey key) throws IOException { WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)key.attachment(); int maxIdleTime = holder.getMaxIdleTime(); if (maxIdleTime < 0) maxIdleTime = (int)getMaxIdleTime(); SelectChannelEndPoint result = new SelectChannelEndPoint(channel, selectSet, key, maxIdleTime); AsyncEndPoint endPoint = result; // Detect if it is SSL, and wrap the connection if so if ("wss".equals(holder.getURI().getScheme())) { SSLEngine sslEngine = newSslEngine(channel); SslConnection sslConnection = new SslConnection(sslEngine, endPoint); endPoint.setConnection(sslConnection); endPoint = sslConnection.getSslEndPoint(); } AsyncConnection connection = selectSet.getManager().newConnection(channel, endPoint, holder); endPoint.setConnection(connection); return result; }
Example #3
Source File: WebSocketClientFactory.java From IoTgo_Android_App with MIT License | 6 votes |
@Override protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, final SelectionKey key) throws IOException { WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)key.attachment(); int maxIdleTime = holder.getMaxIdleTime(); if (maxIdleTime < 0) maxIdleTime = (int)getMaxIdleTime(); SelectChannelEndPoint result = new SelectChannelEndPoint(channel, selectSet, key, maxIdleTime); AsyncEndPoint endPoint = result; // Detect if it is SSL, and wrap the connection if so if ("wss".equals(holder.getURI().getScheme())) { SSLEngine sslEngine = newSslEngine(channel); SslConnection sslConnection = new SslConnection(sslEngine, endPoint); endPoint.setConnection(sslConnection); endPoint = sslConnection.getSslEndPoint(); } AsyncConnection connection = selectSet.getManager().newConnection(channel, endPoint, holder); endPoint.setConnection(connection); return result; }
Example #4
Source File: HttpConductorImpl.java From sql-layer with GNU Affero General Public License v3.0 | 5 votes |
@Override protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endpoint) { AsyncHttpConnection conn = (AsyncHttpConnection)((SslConnection)super.newConnection(channel, endpoint)).getSslEndPoint().getConnection(); ServerSessionMonitor sessionMonitor = new ServerSessionMonitor(SERVER_TYPE, monitorService.allocateSessionId()); conn.setAssociatedObject(sessionMonitor); this.session = sessionService.createSession(); monitorService.registerSessionMonitor(sessionMonitor, session); return conn; }
Example #5
Source File: SslConnection.java From IoTgo_Android_App with MIT License | 5 votes |
public SslConnection(SSLEngine engine,EndPoint endp, long timeStamp) { super(endp,timeStamp); _engine=engine; _session=_engine.getSession(); _aEndp=(AsyncEndPoint)endp; _sslEndPoint = newSslEndPoint(); }
Example #6
Source File: WebSocketConnectionRFC6455.java From IoTgo_Android_App with MIT License | 5 votes |
private void checkWriteable() { if (!_outbound.isBufferEmpty() && _endp instanceof AsyncEndPoint) { ((AsyncEndPoint)_endp).scheduleWrite(); } }
Example #7
Source File: HttpConductorImpl.java From sql-layer with GNU Affero General Public License v3.0 | 5 votes |
@Override protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endpoint) { AsyncHttpConnection conn = (AsyncHttpConnection)super.newConnection(channel, endpoint); ServerSessionMonitor sessionMonitor = new ServerSessionMonitor(SERVER_TYPE, monitorService.allocateSessionId()); conn.setAssociatedObject(sessionMonitor); this.session = sessionService.createSession(); monitorService.registerSessionMonitor(sessionMonitor, session); return conn; }
Example #8
Source File: SslConnection.java From IoTgo_Android_App with MIT License | 5 votes |
public SslConnection(SSLEngine engine,EndPoint endp, long timeStamp) { super(endp,timeStamp); _engine=engine; _session=_engine.getSession(); _aEndp=(AsyncEndPoint)endp; _sslEndPoint = newSslEndPoint(); }
Example #9
Source File: WebSocketConnectionRFC6455.java From IoTgo_Android_App with MIT License | 5 votes |
private void checkWriteable() { if (!_outbound.isBufferEmpty() && _endp instanceof AsyncEndPoint) { ((AsyncEndPoint)_endp).scheduleWrite(); } }
Example #10
Source File: WebSocketConnectionRFC6455.java From WebSocket-for-Android with Apache License 2.0 | 5 votes |
private void checkWriteable() { if (!_outbound.isBufferEmpty() && _endp instanceof AsyncEndPoint) { ((AsyncEndPoint)_endp).scheduleWrite(); } }
Example #11
Source File: SslConnection.java From WebSocket-for-Android with Apache License 2.0 | 5 votes |
public SslConnection(SSLEngine engine,EndPoint endp, long timeStamp) { super(endp,timeStamp); _engine=engine; _session=_engine.getSession(); _aEndp=(AsyncEndPoint)endp; _sslEndPoint = newSslEndPoint(); }
Example #12
Source File: WebSocketConnectionRFC6455.java From WebSocket-for-Android with Apache License 2.0 | 4 votes |
public Connection handle() throws IOException { Thread current = Thread.currentThread(); ClassLoader oldcontext = current.getContextClassLoader(); current.setContextClassLoader(_context); try { // handle the framing protocol boolean progress=true; while (progress) { int flushed=_generator.flushBuffer(); int filled=_parser.parseNext(); progress = flushed>0 || filled>0; _endp.flush(); if (_endp instanceof AsyncEndPoint && ((AsyncEndPoint)_endp).hasProgressed()) progress=true; } } catch(IOException e) { try { if (_endp.isOpen()) _endp.close(); } catch(IOException e2) { LOG.ignore(e2); } throw e; } finally { current.setContextClassLoader(oldcontext); _parser.returnBuffer(); _generator.returnBuffer(); if (_endp.isOpen()) { if (_closedIn && _closedOut && _outbound.isBufferEmpty()) _endp.close(); else if (_endp.isInputShutdown() && !_closedIn) closeIn(CLOSE_NO_CLOSE,null); else checkWriteable(); } } return this; }
Example #13
Source File: WebSocketClientFactory.java From WebSocket-for-Android with Apache License 2.0 | 4 votes |
public HandshakeConnection(AsyncEndPoint endpoint, WebSocketClient.WebSocketFuture future) { super(endpoint, System.currentTimeMillis()); _endp = endpoint; _future = future; byte[] bytes = new byte[16]; new Random().nextBytes(bytes); _key = new String(Base64.encodeToString(bytes, Base64.NO_WRAP)); _extensions = new ArrayList<String>(); Buffers buffers = new SimpleBuffers(_buffers.getBuffer(), null); _parser = new HttpParser(buffers, _endp, new HttpParser.EventHandler() { @Override public void startResponse(Buffer version, int status, Buffer reason) throws IOException { if (status != 101) { _error = "Bad response status " + status + " " + reason; _endp.close(); } } @Override public void parsedHeader(Buffer name, Buffer value) throws IOException { if (__ACCEPT.equals(name)) _accept = value.toString(); else if (__PROTOCOL.equals(name)) _protocol = value.toString(); else if (__EXTENSIONS.equals(name)) for (String s : TextUtils.split(value.toString(), ",")) _extensions.add(s.trim()); } @Override // TODO simone says shouldn't be needed public void startRequest(Buffer method, Buffer url, Buffer version) throws IOException { if (_error == null) _error = "Bad response: " + method + " " + url + " " + version; _endp.close(); } @Override // TODO simone says shouldn't be needed public void content(Buffer ref) throws IOException { if (_error == null) _error = "Bad response. " + ref.length() + "B of content?"; _endp.close(); } }); }
Example #14
Source File: WebSocketClientFactory.java From WebSocket-for-Android with Apache License 2.0 | 4 votes |
@Override public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment) { WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)attachment; return new HandshakeConnection(endpoint, holder); }
Example #15
Source File: SslConnection.java From IoTgo_Android_App with MIT License | 4 votes |
public AsyncEndPoint getEndpoint() { return _aEndp; }
Example #16
Source File: SslConnection.java From WebSocket-for-Android with Apache License 2.0 | 4 votes |
public AsyncEndPoint getSslEndPoint() { return _sslEndPoint; }
Example #17
Source File: WebSocketConnectionRFC6455.java From IoTgo_Android_App with MIT License | 4 votes |
public Connection handle() throws IOException { Thread current = Thread.currentThread(); ClassLoader oldcontext = current.getContextClassLoader(); current.setContextClassLoader(_context); try { // handle the framing protocol boolean progress=true; while (progress) { int flushed=_generator.flushBuffer(); int filled=_parser.parseNext(); progress = flushed>0 || filled>0; _endp.flush(); if (_endp instanceof AsyncEndPoint && ((AsyncEndPoint)_endp).hasProgressed()) progress=true; } } catch(IOException e) { try { if (_endp.isOpen()) _endp.close(); } catch(IOException e2) { LOG.ignore(e2); } throw e; } finally { current.setContextClassLoader(oldcontext); _parser.returnBuffer(); _generator.returnBuffer(); if (_endp.isOpen()) { if (_closedIn && _closedOut && _outbound.isBufferEmpty()) _endp.close(); else if (_endp.isInputShutdown() && !_closedIn) closeIn(CLOSE_NO_CLOSE,null); else checkWriteable(); } } return this; }
Example #18
Source File: SslConnection.java From IoTgo_Android_App with MIT License | 4 votes |
public AsyncEndPoint getSslEndPoint() { return _sslEndPoint; }
Example #19
Source File: WebSocketClientFactory.java From IoTgo_Android_App with MIT License | 4 votes |
public HandshakeConnection(AsyncEndPoint endpoint, WebSocketClient.WebSocketFuture future) { super(endpoint, System.currentTimeMillis()); _endp = endpoint; _future = future; byte[] bytes = new byte[16]; new Random().nextBytes(bytes); _key = new String(B64Code.encode(bytes)); Buffers buffers = new SimpleBuffers(_buffers.getBuffer(), null); _parser = new HttpParser(buffers, _endp, new HttpParser.EventHandler() { @Override public void startResponse(Buffer version, int status, Buffer reason) throws IOException { if (status != 101) { _error = "Bad response status " + status + " " + reason; _endp.close(); } } @Override public void parsedHeader(Buffer name, Buffer value) throws IOException { if (__ACCEPT.equals(name)) _accept = value.toString(); } @Override // TODO simone says shouldn't be needed public void startRequest(Buffer method, Buffer url, Buffer version) throws IOException { if (_error == null) _error = "Bad response: " + method + " " + url + " " + version; _endp.close(); } @Override // TODO simone says shouldn't be needed public void content(Buffer ref) throws IOException { if (_error == null) _error = "Bad response. " + ref.length() + "B of content?"; _endp.close(); } }); }
Example #20
Source File: WebSocketClientFactory.java From IoTgo_Android_App with MIT License | 4 votes |
@Override public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment) { WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)attachment; return new HandshakeConnection(endpoint, holder); }
Example #21
Source File: SslConnection.java From IoTgo_Android_App with MIT License | 4 votes |
public AsyncEndPoint getEndpoint() { return _aEndp; }
Example #22
Source File: SslConnection.java From IoTgo_Android_App with MIT License | 4 votes |
public AsyncEndPoint getSslEndPoint() { return _sslEndPoint; }
Example #23
Source File: WebSocketConnectionRFC6455.java From IoTgo_Android_App with MIT License | 4 votes |
public Connection handle() throws IOException { Thread current = Thread.currentThread(); ClassLoader oldcontext = current.getContextClassLoader(); current.setContextClassLoader(_context); try { // handle the framing protocol boolean progress=true; while (progress) { int flushed=_generator.flushBuffer(); int filled=_parser.parseNext(); progress = flushed>0 || filled>0; _endp.flush(); if (_endp instanceof AsyncEndPoint && ((AsyncEndPoint)_endp).hasProgressed()) progress=true; } } catch(IOException e) { try { if (_endp.isOpen()) _endp.close(); } catch(IOException e2) { LOG.ignore(e2); } throw e; } finally { current.setContextClassLoader(oldcontext); _parser.returnBuffer(); _generator.returnBuffer(); if (_endp.isOpen()) { if (_closedIn && _closedOut && _outbound.isBufferEmpty()) _endp.close(); else if (_endp.isInputShutdown() && !_closedIn) closeIn(CLOSE_NO_CLOSE,null); else checkWriteable(); } } return this; }
Example #24
Source File: WebSocketClientFactory.java From IoTgo_Android_App with MIT License | 4 votes |
public HandshakeConnection(AsyncEndPoint endpoint, WebSocketClient.WebSocketFuture future) { super(endpoint, System.currentTimeMillis()); _endp = endpoint; _future = future; byte[] bytes = new byte[16]; new Random().nextBytes(bytes); _key = new String(B64Code.encode(bytes)); Buffers buffers = new SimpleBuffers(_buffers.getBuffer(), null); _parser = new HttpParser(buffers, _endp, new HttpParser.EventHandler() { @Override public void startResponse(Buffer version, int status, Buffer reason) throws IOException { if (status != 101) { _error = "Bad response status " + status + " " + reason; _endp.close(); } } @Override public void parsedHeader(Buffer name, Buffer value) throws IOException { if (__ACCEPT.equals(name)) _accept = value.toString(); } @Override // TODO simone says shouldn't be needed public void startRequest(Buffer method, Buffer url, Buffer version) throws IOException { if (_error == null) _error = "Bad response: " + method + " " + url + " " + version; _endp.close(); } @Override // TODO simone says shouldn't be needed public void content(Buffer ref) throws IOException { if (_error == null) _error = "Bad response. " + ref.length() + "B of content?"; _endp.close(); } }); }
Example #25
Source File: WebSocketClientFactory.java From IoTgo_Android_App with MIT License | 4 votes |
@Override public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment) { WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)attachment; return new HandshakeConnection(endpoint, holder); }
Example #26
Source File: SelectorManager.java From IoTgo_Android_App with MIT License | votes |
public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment);
Example #27
Source File: SelectorManager.java From IoTgo_Android_App with MIT License | votes |
public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment);
Example #28
Source File: SelectorManager.java From WebSocket-for-Android with Apache License 2.0 | votes |
public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment);