Search in sources :

Example 1 with APrintingReceiveAndSendListener

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);
}
Also used : APrintingReceiveAndSendListener(extraip.APrintingReceiveAndSendListener) ByteBuffer(java.nio.ByteBuffer) DuplexClientInputPort(inputport.datacomm.duplex.DuplexClientInputPort)

Example 2 with APrintingReceiveAndSendListener

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());
    }
}
Also used : Scanner(java.util.Scanner) APrintingReceiveAndSendListener(extraip.APrintingReceiveAndSendListener) ByteBuffer(java.nio.ByteBuffer) DuplexClientInputPort(inputport.datacomm.duplex.DuplexClientInputPort)

Aggregations

APrintingReceiveAndSendListener (extraip.APrintingReceiveAndSendListener)2 DuplexClientInputPort (inputport.datacomm.duplex.DuplexClientInputPort)2 ByteBuffer (java.nio.ByteBuffer)2 Scanner (java.util.Scanner)1