Search in sources :

Example 11 with DuplexRPCClientInputPort

use of inputport.rpc.duplex.DuplexRPCClientInputPort in project GIPC by pdewan.

the class AnOldLatecomerObjectGroupSessionPortLauncher method launchSessionPartipant.

public static void launchSessionPartipant(String anId, String aName, boolean addConnectListener, boolean addReplyingReceiveListener, boolean greetOnReadingInput) {
    PortMisc.displayConnections();
    // Tracer.showInfo(true);
    // Tracer.setKeyWordStatus(Tracer.ALL_KEYWORDS, false);
    // Tracer.setKeyWordStatus("socketip", true);
    // Tracer.setKeyWordStatus("socketdip", true);
    // Tracer.setKeyWordStatus("sesrelaylategrpobj", true);
    // Tracer.setKeyWordStatus("repsrvdupsingleresp", true);
    // Tracer.setKeyWordStatus("repsrvgrpsingleresp", true);
    // Tracer.setKeyWordStatus("sesrelay", true);
    ALatecomerRelayerAndSessionServerLauncherSupport.setLatecomerRelayedCommunicaton(true);
    // GlobalState.setAnyCast(true);
    DelayUtlity.setDelayClientBufferSends(true);
    // DuplexRPCClientInputPort sessionManagerClientPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort(
    // "localhost", "" +
    // ALatecomerSessionsServerLauncher.SESSION_SERVER_PORT,
    // ALatecomerSessionsServerLauncher.SESSION_SERVER_NAME,
    // aName);
    DuplexRPCClientInputPort sessionManagerClientPort = ReplicatedServerDuplexRPCClientPortSelector.createDuplexRPCPort(serversDescription, SESSION_SERVER_NAME, aName, ParticipantChoice.MEMBER);
    DuplexSingleResponseUtlity.supportSingleResponse(sessionManagerClientPort);
    GroupSessionPort<Object> sessionPort = ObjectGroupSessionPortSelector.createObjectGroupSessionPort(sessionManagerClientPort, SESSION_NAME, anId, aName, ParticipantChoice.MEMBER);
    // GlobalState.doCausalBroadcast(sessionPort);
    if (addConnectListener) {
        ConnectionListener connectListener = new AnObjectGroupSendingConnectListener(sessionPort);
        sessionPort.addConnectionListener(connectListener);
    }
    if (addReplyingReceiveListener)
        sessionPort.addReceiveListener(new AnObjectGroupSendingReceiveListener(sessionPort));
    else
        sessionPort.addReceiveListener(new AnEchoingObjectReceiveListener());
    sessionPort.connect();
    System.out.println("-----------------------Connected to Session Port---------------------------------------");
    if (greetOnReadingInput) {
        Scanner in = new Scanner(System.in);
        // sessionPort.sendAll(aName + " says hi to all");
        while (true) {
            System.out.println("Please enter  next input");
            // in = new Scanner(System.in);
            String message = in.nextLine();
            sessionPort.sendAll(message);
        }
    }
}
Also used : Scanner(java.util.Scanner) DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort) AnEchoingObjectReceiveListener(port.delay.example.AnEchoingObjectReceiveListener) ConnectionListener(inputport.ConnectionListener) AnObjectGroupSendingConnectListener(sessionport.datacomm.group.object.example.AnObjectGroupSendingConnectListener) AnObjectGroupSendingReceiveListener(port.delay.example.AnObjectGroupSendingReceiveListener)

Example 12 with DuplexRPCClientInputPort

use of inputport.rpc.duplex.DuplexRPCClientInputPort in project GIPC by pdewan.

the class AReplicatedServerSessionPortFactory method createObjectGroupSessionPort.

public GroupSessionPort createObjectGroupSessionPort(SessionParticipantDescription[] aServerDescriptionList, String anId, String aName, String aSessionServerName, String aSessionName, ParticipantChoice aChoice) {
    // treating a bunch of server ports as a single duplex port
    DuplexRPCClientInputPort sessionManagerClientPort = ReplicatedServerDuplexRPCClientPortSelector.createDuplexRPCPort(aServerDescriptionList, aSessionServerName, aName, // this fails if it is SERVER_ONLY because the idea is to
    ParticipantChoice.MEMBER);
    // create a client port
    // creating a session port out of this
    // this is geared towards the session mananger only.
    // all it does is allow replication of the session manager
    GroupSessionPort<Object> sessionPort = ObjectGroupSessionPortSelector.createObjectGroupSessionPort(sessionManagerClientPort, aSessionName, anId, aName, aChoice);
    return sessionPort;
}
Also used : DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort)

Example 13 with DuplexRPCClientInputPort

use of inputport.rpc.duplex.DuplexRPCClientInputPort 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 14 with DuplexRPCClientInputPort

use of inputport.rpc.duplex.DuplexRPCClientInputPort in project GIPC by pdewan.

the class ADuplexRPCClientMVCLauncher method registerRemoteObjects.

// protected  void createProxies() {
// upperCaseProxy = (DuplexUpperCaser) DirectedRPCProxyGenerator.generateRPCProxy((DuplexRPCClientInputPort) mainPort,
// registeredUpperCaserClass());
// }
protected void registerRemoteObjects() {
    DuplexRPCClientInputPort aDuplexRPCClientInputPort = (DuplexRPCClientInputPort) mainPort;
    counter = new ACounter();
    aDuplexRPCClientInputPort.register(counter);
}
Also used : DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort) ACounter(examples.mvc.local.duplex.ACounter)

Example 15 with DuplexRPCClientInputPort

use of inputport.rpc.duplex.DuplexRPCClientInputPort 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

DuplexRPCClientInputPort (inputport.rpc.duplex.DuplexRPCClientInputPort)17 ConnectionListener (inputport.ConnectionListener)4 Scanner (java.util.Scanner)4 AnObjectGroupSendingConnectListener (sessionport.datacomm.group.object.example.AnObjectGroupSendingConnectListener)4 AnEchoingObjectReceiveListener (port.delay.example.AnEchoingObjectReceiveListener)3 AnObjectGroupSendingReceiveListener (port.delay.example.AnObjectGroupSendingReceiveListener)3 AServerPortDescription (port.sessionserver.AServerPortDescription)3 ServerPortDescription (port.sessionserver.ServerPortDescription)3 Adder (sessionport.rpc.duplex.relayed.example.Adder)3 AnAdder (sessionport.rpc.duplex.relayed.example.AnAdder)3 ACounter (examples.mvc.local.duplex.ACounter)2 DuplexUpperCaser (examples.mvc.local.duplex.DuplexUpperCaser)2 GroupRPCServerInputPort (inputport.rpc.group.GroupRPCServerInputPort)2 RelayerSupportingSessionServer (port.sessionserver.relay.RelayerSupportingSessionServer)2 RPCProxyGenerator (inputport.rpc.RPCProxyGenerator)1 ADuplexRPCInputPortLauncherSupport (inputport.rpc.duplex.ADuplexRPCInputPortLauncherSupport)1 PrintingTypedReceiveListener (oldtypedip.PrintingTypedReceiveListener)1 PrintingTypedReceiveListener (port.old.PrintingTypedReceiveListener)1 ARelayer (port.relay.ARelayer)1 Relayer (port.relay.Relayer)1