Search in sources :

Example 1 with DuplexClientInputPort

use of inputport.datacomm.duplex.DuplexClientInputPort 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 DuplexClientInputPort

use of inputport.datacomm.duplex.DuplexClientInputPort 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)

Example 3 with DuplexClientInputPort

use of inputport.datacomm.duplex.DuplexClientInputPort in project GIPC by pdewan.

the class AJoinerConnectingSessionObserver method processSessionMember.

void processSessionMember(ServerPortDescription aServerPortDescription) {
    if (!myName.equals(aServerPortDescription.getName())) {
        DuplexClientInputPort clientInputPort = DuplexObjectInputPortSelector.createDuplexClientInputPort(aServerPortDescription.getHost(), aServerPortDescription.getID(), aServerPortDescription.getName(), myName);
        clientInputPort.addConnectionListener(new AFrostyObjectConnectionListener(clientInputPort));
        clientInputPort.addReceiveListener(new AnEchoingObjectReceiveListener());
        clientInputPorts.add(clientInputPort);
        clientInputPort.connect();
    // clientInputPort.send("Words of Robert Forst Please");
    // nameToPort.put(aServerPortDescription.getName(), clientInputPort);
    }
}
Also used : AFrostyObjectConnectionListener(inputport.datacomm.duplex.object.echoer.example.AFrostyObjectConnectionListener) AnEchoingObjectReceiveListener(port.delay.example.AnEchoingObjectReceiveListener) DuplexClientInputPort(inputport.datacomm.duplex.DuplexClientInputPort)

Aggregations

DuplexClientInputPort (inputport.datacomm.duplex.DuplexClientInputPort)3 APrintingReceiveAndSendListener (extraip.APrintingReceiveAndSendListener)2 ByteBuffer (java.nio.ByteBuffer)2 AFrostyObjectConnectionListener (inputport.datacomm.duplex.object.echoer.example.AFrostyObjectConnectionListener)1 Scanner (java.util.Scanner)1 AnEchoingObjectReceiveListener (port.delay.example.AnEchoingObjectReceiveListener)1