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();
}
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);
}
}
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);
}
}
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();
}
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();
}
Aggregations