use of extraip.APrintingReceiveAndSendListener in project GIPC by pdewan.
the class AClientDuplexLauncher method launchDuplexClient.
public static void launchDuplexClient(DuplexInputPortFactory factory, String clientName) {
// Tracer.showInfo(true);
DuplexBufferInputPortSelector.setDuplexBufferInputPortFactory(factory);
DuplexClientInputPort clientInputPort = DuplexBufferInputPortSelector.createDuplexClientInputPort("localhost", "9090", "test server", clientName);
APrintingReceiveAndSendListener echoingConnectionListener = new APrintingReceiveAndSendListener(clientInputPort);
clientInputPort.addConnectionListener(echoingConnectionListener);
// clientInputPort.addDisconnectListener(echoingConnectionListener);
clientInputPort.addReceiveListener(echoingConnectionListener);
clientInputPort.addSendListener(echoingConnectionListener);
clientInputPort.connect();
ByteBuffer message = ByteBuffer.wrap("hello server".getBytes());
System.out.println("String with padding:" + new String(message.array()));
clientInputPort.send(message);
}
use of extraip.APrintingReceiveAndSendListener in project GIPC by pdewan.
the class BufferDuplexClientInputPortLauncher method launch.
public static void launch(String[] args) {
DuplexClientInputPort clientInputPort = DuplexBufferInputPortSelector.createDuplexClientInputPort("localhost", "9090", "test server", "test client");
// PrintingReceiveListener echoingConnectionListener = new PrintingReceiveListener();
// clientInputPort.addConnectListener(echoingConnectionListener);
// clientInputPort.addReceiveListener(echoingConnectionListener);
// clientInputPort.connect();
// ByteBuffer message = ByteBuffer.wrap("hello server".getBytes());
// System.out.println("String with padding:" + new String(message.array()));
// clientInputPort.send(message);
APrintingReceiveAndSendListener echoingConnectionListener = new APrintingReceiveAndSendListener(clientInputPort);
clientInputPort.addConnectionListener(echoingConnectionListener);
clientInputPort.addReceiveListener(echoingConnectionListener);
clientInputPort.connect();
String stringMessage = "hello server";
ByteBuffer message = ByteBuffer.wrap(stringMessage.getBytes());
Scanner in = new Scanner(System.in);
while (true) {
clientInputPort.send(message);
stringMessage = in.nextLine();
message = ByteBuffer.wrap(stringMessage.getBytes());
}
}
Aggregations