use of sessionport.rpc.duplex.relayed.example.Adder in project GIPC by pdewan.
the class AGroupRPCServerInputPortLauncher method main.
public static void main(String[] args) {
Tracer.showInfo(true);
GroupRPCServerInputPort serverInputPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort("9090", "test server");
serverInputPort.connect();
PrintingReplyingObjectReceiver messageReceiver = new PrintingReplyingObjectReceiver(serverInputPort);
serverInputPort.addConnectionListener(messageReceiver);
Adder adder = new AnAdder();
serverInputPort.register(Adder.class, adder);
AGroupAdder groupAdder = new AGroupAdder(serverInputPort);
serverInputPort.register(GroupAdder.class, groupAdder);
serverInputPort.addSendListener(messageReceiver);
}
use of sessionport.rpc.duplex.relayed.example.Adder in project GIPC by pdewan.
the class AnOldGroupCallingConnectListener method connected.
@Override
public void connected(String remoteEnd, ConnectionType aConnectionType) {
System.out.print("Connected as client to: " + remoteEnd);
Adder adderProxy = (Adder) GroupRPCProxyGenerator.generateAllRPCProxy(sessionPort, Adder.class, null);
adderProxy.printSum(5, 6);
}
use of sessionport.rpc.duplex.relayed.example.Adder in project GIPC by pdewan.
the class AGroupRPCClientLauncher method launchClient.
public static void launchClient(String aName) {
Tracer.showInfo(true);
RelayerClientAndServerSupport.setRelayedCommunicaton(false);
GroupRPCServerInputPort sessionPort = GroupRPCStaticSessionPortSelector.createGroupRPCStaticSessionPort(servers, REMOTE_END_POINT, aName, "Add Servers", ParticipantChoice.SYMMETRIC_JOIN);
ConnectionListener connectListener = new AnOldGroupCallingConnectListener(sessionPort);
sessionPort.addConnectionListener(connectListener);
Adder adder = new AnAdder();
sessionPort.register(Adder.class, adder);
Scanner in = new Scanner(System.in);
String message = in.nextLine();
Tracer.info("About to connect to peers");
sessionPort.connect();
in.nextLine();
}
use of sessionport.rpc.duplex.relayed.example.Adder in project GIPC by pdewan.
the class ADuplexRPCClientLauncher method launchRPCClient.
public static void launchRPCClient(String clientName) {
Tracer.showInfo(true);
DuplexRPCClientInputPort clientInputPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort("localhost", "9090", "test client", clientName);
PrintingTypedReceiveListener messageReceiver = new PrintingTypedReceiveListener(clientInputPort);
clientInputPort.addConnectionListener(messageReceiver);
// clientInputPort.addDisconnectListener(messageReceiver);
// clientInputPort.register(messageReceiver.getClass(), messageReceiver);
//
// clientInputPort.addTypedReceiveListener(messageReceiver);
clientInputPort.addSendListener(messageReceiver);
// clientInputPort.register(TypedReceiveListener.class, messageReceiver);
Adder adder = new AnAdder();
clientInputPort.register(Adder.class, adder);
clientInputPort.connect();
// clientInputPort.send("hello from" + clientName);
try {
// Class[] parameterTypes = {Integer.class, Integer.class};
// Method rpcMethod = Adder.class.getMethod("add", parameterTypes);
// Serializable[] args = {5, 7};
// clientInputPort.call(Adder.class, rpcMethod, args);
// Method rpcMethod = RPCReceiver.class.getMethod("messageReceived", parameterTypes);
// Serializable[] args = {clientName, "hello from " + clientName};
// clientInputPort.call(typedMethod, args);
// clientInputPort.call(RPCReceiver.class, rpcMethod, args);
// Method groupAddMethod = GroupAdder.class.getMethod("messageReceived", parameterTypes);
// clientInputPort.call(GroupAdder.class, groupAddMethod, args);
// Integer[] args2 = { 5, 6};
// Class[] parameterTypes2 = {Integer.class, Integer.class};
// Method intAddMethod = Adder.class.getMethod("add", parameterTypes2);
// // Object retVal = clientInputPort.call(Adder.class, intAddMethod, args2);
// Integer[] args3 = { 5, 6};
// Class[] parameterTypes3 = {Integer.TYPE, Integer.TYPE};
// Method intAddMethod2 = Adder.class.getMethod("add", parameterTypes2);
// Object retVal2 = clientInputPort.call(Adder.class, intAddMethod, args2);
// System.out.println(retVal2);
// GroupAdder groupAdderProxy = (GroupAdder) RPCProxyGenerator.generateUniRPCProxy(clientInputPort, GroupAdder.class, null);
// groupAdderProxy.groupAdd(5, 6);
Adder adderProxy = (Adder) DirectedRPCProxyGenerator.generateRPCProxy(clientInputPort, null, Adder.class, null);
Object result = adderProxy.sum(5, 6);
System.out.println("Result of adding:" + result);
// DuplexAdder duplexAdderProxy = (DuplexAdder) UniRPCProxyGenerator.generateUniRPCProxy(clientInputPort, Adder.class, null);
DuplexAdder duplexAdderProxy = (DuplexAdder) DirectedRPCProxyGenerator.generateRPCProxy(clientInputPort, null, DuplexAdder.class, null);
duplexAdderProxy.duplexSum(5, 6);
CallingBackSquareAdder callbackAdderProxy = (CallingBackSquareAdder) DirectedRPCProxyGenerator.generateRPCProxy(clientInputPort, null, CallingBackSquareAdder.class, null);
RemoteAdder remoteAdder = new ARemoteAdder();
callbackAdderProxy.add(remoteAdder, 2, 3);
callbackAdderProxy.add(remoteAdder, 4, 2);
RemoteAdderGetter remoteAdderGetter = (RemoteAdderGetter) DirectedRPCProxyGenerator.generateRPCProxy(clientInputPort, null, RemoteAdderGetter.class, null);
RemoteAdder receivedRemoteAdder = remoteAdderGetter.getRemoteAdder();
Object retVal = receivedRemoteAdder.sum(5, 5);
System.out.println(retVal);
// System.out.println("Result of duplex adding:" + result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of sessionport.rpc.duplex.relayed.example.Adder in project GIPC by pdewan.
the class AGroupRPCAdderServerLauncher method registerRemoteObjects.
protected void registerRemoteObjects() {
Adder adder = new AnAdder();
((GroupRPCServerInputPort) mainPort).register(Adder.class, adder);
}
Aggregations