use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.
the class SslChannelService method createTCPChannel.
@Override
public TCPChannel createTCPChannel(String id, SSLEngine engine) {
if (engine == null || id == null)
throw new IllegalArgumentException("no arguments can be null");
Function<SslListener, AsyncSSLEngine> function = l -> AsyncSSLFactory.create(id, engine, pool, l);
TCPChannel channel = mgr.createTCPChannel(id);
SslTCPChannel sslChannel = new SslTCPChannel(function, channel);
return sslChannel;
}
use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.
the class EventClient method start.
public void start() throws IOException, InterruptedException {
ChannelService mgr = ChannelServiceFactory.createDefaultChannelMgr("EventServer");
mgr.start();
SSLEngineFactory sslFactory = new MockSSLEngineFactory();
Settings h = new Settings(sslFactory, null);
TCPChannel channel = mgr.createTCPChannel("SvrChan", h);
InetAddress addr = InetAddress.getByName("192.168.1.102");
InetSocketAddress sockAddr = new InetSocketAddress(addr, 801);
log.info("Connecting to server=" + sockAddr);
channel.oldConnect(sockAddr, this);
}
use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.
the class TryRealConnection method xxxtestRealConnection.
public void xxxtestRealConnection() throws Exception {
MockObject mockConnect = MockObjectFactory.createMock(ConnectionCallback.class);
Settings h = new Settings(new MockSSLEngineFactory(), null);
TCPChannel channel = chanMgr.createTCPChannel("testId", h);
channel.bind(loopBackAddr);
log.trace("aaaaa");
MockObject handler = new MockDataHandler();
channel.registerForReads((DataListener) handler);
// InetAddress host = InetAddress.getByName("shell.sourceforge.net");
InetAddress host = InetAddress.getByName("www.xsoftware.biz");
InetSocketAddress addr = new InetSocketAddress(host, 22);
channel.oldConnect(addr, (ConnectionCallback) mockConnect);
mockConnect.expect("connected");
handler.addIgnore("getBuffer");
//CalledMethod method =
handler.expect("incomingData");
// ByteBuffer b = (ByteBuffer)method.getAllParams()[1];
}
use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.
the class TestExample method runClient.
private void runClient(SocketAddress svrAddr) throws Exception {
TCPChannel client = svc.createTCPChannel("client", null);
client.bind(new InetSocketAddress(0));
//we will just go with synchronous connect today...(could have used the asynch one though)
client.oldConnect(svrAddr);
client.registerForReads(new MyDataListener("client"));
//because this is not a real example and the server and client are both here, we
//will sleep and wait for the svrTCPChannel to be cached!! Normally, this is
//not needed
Thread.sleep(2000);
String msg = "hello world";
ByteBuffer b = ByteBuffer.allocate(100);
HELPER.putString(b, msg);
b.flip();
client.oldWrite(b);
b.rewind();
svrTCPChannel.oldWrite(b);
}
use of org.webpieces.nio.api.channels.TCPChannel in project webpieces by deanhiller.
the class TestExampleSessions method runClient.
private void runClient(SocketAddress svrAddr) throws Exception {
TCPChannel client = svc.createTCPChannel("client", null);
client.bind(new InetSocketAddress(0));
//we will just go with synchronous connect today...(could have used the asynch one though)
client.oldConnect(svrAddr);
client.registerForReads(new MyDataListener("client"));
//because this is not a real example and the server and client are both here, we
//will sleep and wait for the svrTCPChannel to be cached!! Normally, this is
//not needed
Thread.sleep(2000);
String msg = "hello world";
ByteBuffer b = ByteBuffer.allocate(100);
HELPER.putString(b, msg);
b.flip();
client.oldWrite(b);
b.rewind();
client.oldWrite(b);
b.rewind();
svrTCPChannel.oldWrite(b);
b.rewind();
client.oldWrite(b);
}
Aggregations