Search in sources :

Example 6 with AnAdder

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

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

Example 8 with AnAdder

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

Example 9 with AnAdder

use of sessionport.rpc.duplex.relayed.example.AnAdder in project GIPC by pdewan.

the class AGroupRPCAdderServerLauncher method registerRemoteObjects.

protected void registerRemoteObjects() {
    Adder adder = new AnAdder();
    ((GroupRPCServerInputPort) mainPort).register(Adder.class, adder);
}
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 10 with AnAdder

use of sessionport.rpc.duplex.relayed.example.AnAdder in project GIPC by pdewan.

the class AnOldSessionClientLauncher method launch.

public static void launch(String myHost, String myID, String myName) {
    GroupRPCServerInputPort serverInputPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort(myID, myName);
    Adder adder = new AnAdder();
    serverInputPort.register(Adder.class, adder);
    serverInputPort.connect();
    // SessionObserver observer = new APrintingSessionObserver();
    SessionObserver observer = new AJoinerConnectingSessionObserver(myName);
    ServerPortDescription sessionClientDescription = new AServerPortDescription(myHost, myID, myName);
    DuplexRPCClientInputPort clientInputPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort("localhost", "" + SESSION_SERVER_PORT, SESSION_SERVER_NAME, myName);
    clientInputPort.connect();
    try {
        SessionServer sessionServerProxy = (SessionServer) DirectedRPCProxyGenerator.generateRPCProxy(clientInputPort, null, SessionServer.class, null);
        Object retVal = sessionServerProxy.join("Test Session", sessionClientDescription, observer);
        System.out.println(retVal);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ServerPortDescription(port.sessionserver.ServerPortDescription) AServerPortDescription(port.sessionserver.AServerPortDescription) DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort) SessionObserver(port.sessionserver.SessionObserver) AServerPortDescription(port.sessionserver.AServerPortDescription) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) Adder(sessionport.rpc.duplex.relayed.example.Adder) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) SessionServer(port.sessionserver.SessionServer) GroupRPCServerInputPort(inputport.rpc.group.GroupRPCServerInputPort)

Aggregations

Adder (sessionport.rpc.duplex.relayed.example.Adder)11 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