Search in sources :

Example 1 with ConnectionListener

use of inputport.ConnectionListener 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 ConnectionListener

use of inputport.ConnectionListener in project GIPC by pdewan.

the class ARelayerConnectingConnectListener method participateInSession.

@Override
protected void participateInSession() {
    ConnectionListener connectionListener = ASessionServerClientLauncher.createParticipatingConnectionListener(inputPort, participantChoice, ARelayerSupportingSessionServer.class, serverPortDescription, sessionObserver, uiCreator);
    ServerPortDescription relayerDesccription = ((RelayerSupportingSessionServer) sessionServerProxy).getRelayerDescripton(sessionName);
    if (relayerDesccription == null) {
        relayerPort = (DuplexRPCClientInputPort) inputPort;
    // relayerPort.addReceiveListener(receiveListener);
    // connectionListener.connected(relayerPort.getLogicalRemoteEndPoint()); // fake a connection
    // return;
    } else {
        relayerPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort(relayerDesccription.getHost(), relayerDesccription.getID(), relayerDesccription.getName(), myName);
    }
    try {
        relayerProxy = (Relayer) DirectedRPCProxyGenerator.generateRPCProxy((DuplexRPCClientInputPort) relayerPort, null, ARelayer.class, null);
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (// JOIN_ONLY
    sessionObserver != null)
        sessionObserver.setRelayerProxy(relayerProxy);
    // relayerPort.addConnectionListener(
    // ASessionServerClientLauncher.createParticipatingConnectionListener(
    // inputPort, participantChoice, RelayerSupportingSessionServer.class,  serverPortDescription, sessionObserver, uiCreator));
    relayerPort.addReceiveListener(receiveListener);
    if (relayerPort != inputPort) {
        relayerPort.addConnectionListener(connectionListener);
        // relayerPort.addReceiveListener(receiveListener);
        relayerPort.connect();
    } else {
        // fake a connection
        connectionListener.connected(relayerPort.getLogicalRemoteEndPoint(), null);
    }
}
Also used : ServerPortDescription(port.sessionserver.ServerPortDescription) RelayerSupportingSessionServer(port.sessionserver.relay.RelayerSupportingSessionServer) ARelayerSupportingSessionServer(port.sessionserver.relay.ARelayerSupportingSessionServer) ConnectionListener(inputport.ConnectionListener)

Example 3 with ConnectionListener

use of inputport.ConnectionListener in project GIPC by pdewan.

the class AFaultTolerantSessionPortLauncher method launchSessionPartipant.

public static void launchSessionPartipant(String anId, String aName, boolean addConnectListener, boolean addReplyingReceiveListener, boolean greetOnReadingInput) {
    Tracer.showInfo(true);
    RelayerClientAndServerSupport.setRelayedCommunicaton(false);
    DelayUtlity.setDelayClientBufferSends(true);
    // GlobalState.setCausalBroadcast(true);
    // GroupSessionPort<Object> groupSessionPort = ObjectGroupStaticSessionPortSelector.createObjectGroupStaticSessionPort(serversDescription, null, aName);
    // GroupMultiServerClientPort<Object> groupMultiServerPort = ObjectGroupMultiServerPortSelector.createGroupMultiServerClientPort(serversDescription, null, aName);
    // DuplexClientInputPort<Object> sessionsServerObjectPort = new AReplicatedServerDuplexClientPort<Object>(groupMultiServerPort, SESSION_SERVER_NAME );
    // DuplexRPCClientInputPort sessionsServerClientPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort(sessionsServerObjectPort);
    DuplexRPCClientInputPort sessionsServerClientPort = ReplicatedServerDuplexRPCClientPortSelector.createDuplexRPCPort(serversDescription, SESSION_SERVER_NAME, aName, ParticipantChoice.SYMMETRIC_JOIN);
    DuplexSingleResponseUtlity.supportSingleResponse(sessionsServerClientPort);
    // GlobalState.setDelayAndCausal(true);
    // DuplexRPCClientInputPort sessionManagerClientPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort(
    // "localhost", "" +  SESSION_SERVER_PORT, SESSION_SERVER_NAME, aName);
    GroupSessionPort<Object> sessionPort = ObjectGroupSessionPortSelector.createObjectGroupSessionPort(sessionsServerClientPort, "Test Session", anId, aName, ParticipantChoice.MEMBER);
    ACausalGroupSessionPortLauncherSupport.doCausalBroadcast(sessionPort);
    // PrintingReplyingReceiveListener printingReplyingReceiveListener = new PrintingReplyingReceiveListener(sessionPort);
    if (addConnectListener) {
        ConnectionListener connectListener = new AnObjectGroupSendingConnectListener(sessionPort);
        // sessionPort.addConnectListener(printingReplyingReceiveListener);
        sessionPort.addConnectionListener(connectListener);
    }
    if (addReplyingReceiveListener)
        sessionPort.addReceiveListener(new AnObjectGroupSendingReceiveListener(sessionPort));
    else
        sessionPort.addReceiveListener(new AnEchoingObjectReceiveListener());
    // serverInputPort.addDisconnectListener(echoingReceiveListener);
    // sessionPort.addReceiveListener(printingReplyingReceiveListener);
    sessionPort.connect();
    System.out.println("-----------------------Connected to Session Port---------------------------------------");
    Scanner in = new Scanner(System.in);
    if (greetOnReadingInput) {
        String message = in.nextLine();
        sessionPort.sendAll(aName + " says hi to all");
    }
    while (true) {
        String message = in.nextLine();
        sessionPort.sendAll(aName + 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 4 with ConnectionListener

use of inputport.ConnectionListener 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 5 with ConnectionListener

use of inputport.ConnectionListener 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)

Aggregations

ConnectionListener (inputport.ConnectionListener)14 Scanner (java.util.Scanner)6 DuplexRPCClientInputPort (inputport.rpc.duplex.DuplexRPCClientInputPort)4 AnObjectGroupSendingConnectListener (sessionport.datacomm.group.object.example.AnObjectGroupSendingConnectListener)4 Adder (sessionport.rpc.duplex.relayed.example.Adder)4 AnAdder (sessionport.rpc.duplex.relayed.example.AnAdder)4 AnEchoingObjectReceiveListener (port.delay.example.AnEchoingObjectReceiveListener)3 AnObjectGroupSendingReceiveListener (port.delay.example.AnObjectGroupSendingReceiveListener)3 AnOldGroupCallingConnectListener (sessionport.rpc.group.AnOldGroupCallingConnectListener)3 ByteBuffer (java.nio.ByteBuffer)2 ABufferDuplexReceiveListener (sessionport.datacomm.duplex.buffer.ABufferDuplexReceiveListener)2 AnObjectDuplexReceiveListener (sessionport.datacomm.duplex.object.AnObjectDuplexReceiveListener)2 DuplexRPCSessionPort (sessionport.rpc.duplex.DuplexRPCSessionPort)2 GroupRPCSessionPort (sessionport.rpc.group.GroupRPCSessionPort)2 GroupRPCServerInputPort (inputport.rpc.group.GroupRPCServerInputPort)1 ServerPortDescription (port.sessionserver.ServerPortDescription)1 ARelayerSupportingSessionServer (port.sessionserver.relay.ARelayerSupportingSessionServer)1 RelayerSupportingSessionServer (port.sessionserver.relay.RelayerSupportingSessionServer)1 ASendingConnectListener (sessionport.datacomm.duplex.buffer.ASendingConnectListener)1 ADirectObjectDuplexSessionPortFactory (sessionport.datacomm.duplex.object.direct.ADirectObjectDuplexSessionPortFactory)1