Search in sources :

Example 1 with Adder

use of sessionport.rpc.duplex.relayed.example.Adder 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();
}
Also used : ACallingConnectListener(sessionport.rpc.duplex.relayed.example.ACallingConnectListener) ADirectObjectDuplexSessionPortFactory(sessionport.datacomm.duplex.object.direct.ADirectObjectDuplexSessionPortFactory) DuplexRPCSessionPort(sessionport.rpc.duplex.DuplexRPCSessionPort) ConnectionListener(inputport.ConnectionListener) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) Adder(sessionport.rpc.duplex.relayed.example.Adder) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder)

Example 2 with Adder

use of sessionport.rpc.duplex.relayed.example.Adder 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();
}
Also used : AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) Adder(sessionport.rpc.duplex.relayed.example.Adder) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) GroupRPCServerInputPort(inputport.rpc.group.GroupRPCServerInputPort)

Example 3 with Adder

use of sessionport.rpc.duplex.relayed.example.Adder 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();
}
Also used : Scanner(java.util.Scanner) GroupRPCSessionPort(sessionport.rpc.group.GroupRPCSessionPort) AnOldGroupCallingConnectListener(sessionport.rpc.group.AnOldGroupCallingConnectListener) ConnectionListener(inputport.ConnectionListener) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) Adder(sessionport.rpc.duplex.relayed.example.Adder) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder)

Example 4 with Adder

use of sessionport.rpc.duplex.relayed.example.Adder 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();
}
Also used : GroupRPCSessionPort(sessionport.rpc.group.GroupRPCSessionPort) AnOldGroupCallingConnectListener(sessionport.rpc.group.AnOldGroupCallingConnectListener) ConnectionListener(inputport.ConnectionListener) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) Adder(sessionport.rpc.duplex.relayed.example.Adder) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder)

Example 5 with Adder

use of sessionport.rpc.duplex.relayed.example.Adder 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();
    }
}
Also used : DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort) PrintingTypedReceiveListener(port.old.PrintingTypedReceiveListener) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) Adder(sessionport.rpc.duplex.relayed.example.Adder) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder)

Aggregations

Adder (sessionport.rpc.duplex.relayed.example.Adder)12 AnAdder (sessionport.rpc.duplex.relayed.example.AnAdder)11 GroupRPCServerInputPort (inputport.rpc.group.GroupRPCServerInputPort)5 ConnectionListener (inputport.ConnectionListener)4 DuplexRPCClientInputPort (inputport.rpc.duplex.DuplexRPCClientInputPort)3 AnOldGroupCallingConnectListener (sessionport.rpc.group.AnOldGroupCallingConnectListener)3 Scanner (java.util.Scanner)2 DuplexRPCSessionPort (sessionport.rpc.duplex.DuplexRPCSessionPort)2 GroupRPCSessionPort (sessionport.rpc.group.GroupRPCSessionPort)2 PrintingTypedReceiveListener (oldtypedip.PrintingTypedReceiveListener)1 PrintingReplyingObjectReceiver (port.old.PrintingReplyingObjectReceiver)1 PrintingTypedReceiveListener (port.old.PrintingTypedReceiveListener)1 AServerPortDescription (port.sessionserver.AServerPortDescription)1 ServerPortDescription (port.sessionserver.ServerPortDescription)1 SessionObserver (port.sessionserver.SessionObserver)1 SessionServer (port.sessionserver.SessionServer)1 ADirectObjectDuplexSessionPortFactory (sessionport.datacomm.duplex.object.direct.ADirectObjectDuplexSessionPortFactory)1 ACallingConnectListener (sessionport.rpc.duplex.relayed.example.ACallingConnectListener)1