Search in sources :

Example 16 with TCPChannel

use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.

the class ProxyDataListener method failure.

@Override
public void failure(Channel channel, ByteBuffer data, Exception e) {
    TCPChannel proxy = lookupExistingOrCreateNew(channel);
    dataListener.failure(proxy, data, e);
}
Also used : TCPChannel(org.webpieces.nio.api.channels.TCPChannel)

Example 17 with TCPChannel

use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.

the class ProxyDataListener method connectionOpened.

public void connectionOpened(Channel channel, boolean isReadyForWrites) {
    TCPChannel proxy = lookupExistingOrCreateNew(channel);
    dataListener.connectionOpened(proxy, isReadyForWrites);
}
Also used : TCPChannel(org.webpieces.nio.api.channels.TCPChannel)

Example 18 with TCPChannel

use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.

the class TestBasicSslClientServer method testBasic.

@Test
public void testBasic() throws InterruptedException {
    pool = new BufferCreationPool();
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager mgr = factory.createSingleThreadedChanMgr("sslChanMgr", pool);
    AsyncServerManager svrFactory = AsyncServerMgrFactory.createAsyncServer(mgr);
    SSLEngineFactoryForTest f = new SSLEngineFactoryForTest();
    InetSocketAddress addr = new InetSocketAddress("localhost", 0);
    AsyncServer svr = svrFactory.createTcpServer(new AsyncConfig("sslTcpSvr"), new SvrDataListener(), f);
    svr.start(addr);
    InetSocketAddress bound = svr.getUnderlyingChannel().getLocalAddress();
    System.out.println("port=" + bound.getPort());
    TCPChannel channel = mgr.createTCPChannel("client", f.createEngineForSocket());
    CompletableFuture<Channel> connect = channel.connect(bound, new ClientListener());
    connect.thenAccept(c -> writeData(c));
    synchronized (pool) {
        while (values.size() < 10) pool.wait();
    }
    for (int i = 0; i < values.size(); i++) {
        Assert.assertEquals(new Integer(i), values.get(i));
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) TCPChannel(org.webpieces.nio.api.channels.TCPChannel) AsyncServer(org.webpieces.asyncserver.api.AsyncServer) Channel(org.webpieces.nio.api.channels.Channel) TCPChannel(org.webpieces.nio.api.channels.TCPChannel) AsyncConfig(org.webpieces.asyncserver.api.AsyncConfig) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) Test(org.junit.Test)

Example 19 with TCPChannel

use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.

the class ProxyDataListener method incomingData.

@Override
public void incomingData(Channel channel, ByteBuffer b) {
    TCPChannel proxy = lookupExistingOrCreateNew(channel);
    dataListener.incomingData(proxy, b);
}
Also used : TCPChannel(org.webpieces.nio.api.channels.TCPChannel)

Example 20 with TCPChannel

use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.

the class ProxyDataListener method releaseBackPressure.

@Override
public void releaseBackPressure(Channel channel) {
    TCPChannel proxy = lookupExistingOrCreateNew(channel);
    dataListener.releaseBackPressure(proxy);
}
Also used : TCPChannel(org.webpieces.nio.api.channels.TCPChannel)

Aggregations

TCPChannel (org.webpieces.nio.api.channels.TCPChannel)39 InetSocketAddress (java.net.InetSocketAddress)12 ByteBuffer (java.nio.ByteBuffer)10 CalledMethod (biz.xsoftware.mock.CalledMethod)8 CloneByteBuffer (org.webpieces.nio.api.testutil.CloneByteBuffer)6 ChannelManager (org.webpieces.nio.api.ChannelManager)5 Channel (org.webpieces.nio.api.channels.Channel)5 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)4 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)4 FutureOperation (org.webpieces.nio.api.handlers.FutureOperation)4 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)3 AsyncServer (org.webpieces.asyncserver.api.AsyncServer)3 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)3 BufferPool (org.webpieces.data.api.BufferPool)3 PerfTimer (org.webpieces.nio.test.PerfTimer)3 IOException (java.io.IOException)2 InetAddress (java.net.InetAddress)2 Executor (java.util.concurrent.Executor)2 Test (org.junit.Test)2 TCPServerChannel (org.webpieces.nio.api.channels.TCPServerChannel)2