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);
}
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());
}
}
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);
}
}
Aggregations