org.eclipse.jetty.io.nio.AsyncConnection Java Examples

The following examples show how to use org.eclipse.jetty.io.nio.AsyncConnection. 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 vote down vote up
@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 IoTgo_Android_App with MIT License 6 votes vote down vote up
@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 WebSocket-for-Android with Apache License 2.0 6 votes vote down vote up
@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 vote down vote up
@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 #5
Source File: HttpConductorImpl.java    From sql-layer with GNU Affero General Public License v3.0 5 votes vote down vote up
@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 #6
Source File: WebSocketClientFactory.java    From IoTgo_Android_App with MIT License 4 votes vote down vote up
@Override
public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment)
{
    WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)attachment;
    return new HandshakeConnection(endpoint, holder);
}
 
Example #7
Source File: WebSocketClientFactory.java    From IoTgo_Android_App with MIT License 4 votes vote down vote up
@Override
public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment)
{
    WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)attachment;
    return new HandshakeConnection(endpoint, holder);
}
 
Example #8
Source File: WebSocketClientFactory.java    From WebSocket-for-Android with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment)
{
    WebSocketClient.WebSocketFuture holder = (WebSocketClient.WebSocketFuture)attachment;
    return new HandshakeConnection(endpoint, holder);
}