use of sessionport.rpc.duplex.relayed.example.AnAdder in project GIPC by pdewan.
the class ADuplexRPCDirectSessionPortLauncher method launchSessionPartipant.
public static void launchSessionPartipant(String anId, String aName, ParticipantChoice aChoice) {
// Tracer.showInfo(true);
ObjectDuplexSessionPortSelector.setDuplexSessionPortFactory(new ADirectObjectDuplexSessionPortFactory());
// ObjectDuplexSessionPortSelector.setDuplexSessionPortFactory(
// new ARelayingObjectDuplexSessionPortFactory());
DuplexRPCSessionPort sessionPort = DuplexRPCSessionPortSelector.createDuplexRPCSessionPort("localhost", "" + SESSION_SERVER_PORT, SESSION_SERVER_NAME, "Test Session", anId, aName, aChoice);
// DuplexRPCSessionPort sessionPort = DuplexRPCSessionPortSelector.createDuplexRPCSessionPort("localhost",
// "" + SESSION_SERVER_PORT, aSessionServerName, "Test Session", anId, aName,
// aChoice
// );
ConnectionListener connectListener = new ACallingConnectListener(sessionPort);
sessionPort.addConnectionListener(connectListener);
Adder adder = new AnAdder();
sessionPort.register(Adder.class, adder);
sessionPort.connect();
}
use of sessionport.rpc.duplex.relayed.example.AnAdder in project GIPC by pdewan.
the class AGroupRPCServerLauncher method launchGroupServer.
public static void launchGroupServer(String anId, String aName) {
Tracer.showInfo(true);
RelayerClientAndServerSupport.setRelayedCommunicaton(false);
GroupRPCServerInputPort serverPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort(anId, aName);
// ConnectListener connectListener = new AGroupCallingConnectListener(serverPort);
// serverPort.addConnectListener(connectListener);
Adder adder = new AnAdder();
serverPort.register(Adder.class, adder);
serverPort.connect();
}
use of sessionport.rpc.duplex.relayed.example.AnAdder in project GIPC by pdewan.
the class AnOlderGroupRPCStaticSessionPortLauncher method launchStaticSessionPartipant.
public static void launchStaticSessionPartipant(ServerPortDescription[] aServerList, String anId, String aName) {
Tracer.showInfo(true);
RelayerClientAndServerSupport.setRelayedCommunicaton(false);
GroupRPCSessionPort sessionPort = null;
// fix this later if needed
// GroupRPCStaticSessionPortSelector.createGroupRPCStaticSessionPort(aServerList, anId, aName, REMOTE_END_POINT, null
// );
ConnectionListener connectListener = new AnOldGroupCallingConnectListener(sessionPort);
sessionPort.addConnectionListener(connectListener);
Adder adder = new AnAdder();
sessionPort.register(Adder.class, adder);
Scanner in = new Scanner(System.in);
System.out.println("Press any key to connect to peers");
String message = in.nextLine();
Tracer.info("About to connect to peers");
sessionPort.connect();
}
use of sessionport.rpc.duplex.relayed.example.AnAdder in project GIPC by pdewan.
the class AnOldestGroupRPCSessionPortLauncher method launchSessionPartipant.
public static void launchSessionPartipant(String anId, String aName) {
Tracer.showInfo(true);
RelayerClientAndServerSupport.setRelayedCommunicaton(false);
GroupRPCSessionPort sessionPort = GroupRPCSessionPortSelector.createGroupRPCSessionPort("localhost", "" + SESSION_SERVER_PORT, SESSION_SERVER_NAME, "Test Session", anId, aName, ParticipantChoice.MEMBER);
ConnectionListener connectListener = new AnOldGroupCallingConnectListener(sessionPort);
sessionPort.addConnectionListener(connectListener);
Adder adder = new AnAdder();
sessionPort.register(Adder.class, adder);
sessionPort.connect();
}
use of sessionport.rpc.duplex.relayed.example.AnAdder in project GIPC by pdewan.
the class AnRPCClientLauncher method launchRPCClient.
public static void launchRPCClient(String clientName) {
// Tracer.showInfo(true);
DuplexRPCClientInputPort clientInputPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort("localhost", "9090", "Test Server", clientName);
PrintingTypedReceiveListener messageReceiver = new PrintingTypedReceiveListener(clientInputPort);
clientInputPort.addConnectionListener(messageReceiver);
// clientInputPort.addDisconnectListener(messageReceiver);
clientInputPort.register(messageReceiver.getClass(), messageReceiver);
clientInputPort.addReceiveListener(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 = {String.class, Serializable.class};
// Method typedMethod = TypedReceiveListener.class.getMethod("messageReceived", parameterTypes);
// 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) DirectedRPCProxyGenerator.generateRPCProxy(clientInputPort, null, GroupAdder.class, null);
groupAdderProxy.groupSum(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);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations