use of org.eclipse.ecf.core.events.IContainerConnectedEvent in project ecf by eclipse.
the class MyChannel method initialize.
protected void initialize() throws SharedObjectInitException {
super.initialize();
// Add event processor that responds to IContainerConnectedEvent messages
addEventProcessor(new IEventProcessor() {
public boolean processEvent(Event event) {
// If event is IContainerConnectedEvent
if (event instanceof IContainerConnectedEvent) {
IContainerConnectedEvent ccevent = (IContainerConnectedEvent) event;
// Check to make sure it's a client...not the groupID
if (!ccevent.getTargetID().equals(getConnectedID()))
sendHelloMessage();
}
return false;
}
});
}
use of org.eclipse.ecf.core.events.IContainerConnectedEvent in project ecf by eclipse.
the class MSNConnectWizard method performFinish.
public boolean performFinish() {
final String connectID = page.getEmail();
final String password = page.getPassword();
// Save combo text even if we don't successfully login
page.saveComboText();
connectContext = ConnectContextFactory.createPasswordConnectContext(password);
try {
targetID = container.getConnectNamespace().createInstance(new Object[] { connectID });
} catch (final IDCreateException e) {
new IDCreateErrorDialog(null, connectID, e).open();
return false;
}
page.saveComboItems();
final IPresenceContainerAdapter adapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
container.addListener(new IContainerListener() {
public void handleEvent(IContainerEvent event) {
if (event instanceof IContainerConnectedEvent) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
openView();
}
});
}
}
});
final IChatManager icm = adapter.getChatManager();
icms = icm.getChatMessageSender();
itms = icm.getTypingMessageSender();
icm.addMessageListener(new IIMMessageListener() {
public void handleMessageEvent(IIMMessageEvent e) {
if (e instanceof IChatMessageEvent) {
displayMessage((IChatMessageEvent) e);
} else if (e instanceof ITypingMessageEvent) {
displayTypingNotification((ITypingMessageEvent) e);
}
}
});
new AsynchContainerConnectAction(container, targetID, connectContext, null, new Runnable() {
public void run() {
cachePassword(connectID, password);
}
}).run();
return true;
}
use of org.eclipse.ecf.core.events.IContainerConnectedEvent in project ecf by eclipse.
the class OptimisticSharedObject method initialize.
protected void initialize() throws SharedObjectInitException {
super.initialize();
Trace.entering(Activator.PLUGIN_ID, SharedObjectDebugOptions.METHODS_ENTERING, OptimisticSharedObject.class, // $NON-NLS-1$
"initialize");
addEventProcessor(new IEventProcessor() {
public boolean processEvent(Event event) {
if (event instanceof ISharedObjectActivatedEvent) {
// then replicate to all remotes
if (isPrimary() && isConnected()) {
OptimisticSharedObject.this.replicateToRemoteContainers(null);
}
} else if (event instanceof IContainerConnectedEvent) {
// then replicate to the newly arrived container
if (isPrimary()) {
ID targetID = ((IContainerConnectedEvent) event).getTargetID();
OptimisticSharedObject.this.replicateToRemoteContainers(new ID[] { targetID });
}
}
return false;
}
});
Trace.exiting(Activator.PLUGIN_ID, SharedObjectDebugOptions.METHODS_EXITING, OptimisticSharedObject.class, // $NON-NLS-1$
"initialize");
}
use of org.eclipse.ecf.core.events.IContainerConnectedEvent in project ecf by eclipse.
the class ClientContainerConnectTest method testListenerConnected.
public void testListenerConnected() throws Exception {
final IContainer client = getClients()[0];
client.addListener(createListener());
client.connect(createServerID(), null);
final Object o = clientConnectedEvents.get(0);
assertTrue(o instanceof IContainerConnectedEvent);
final IContainerConnectedEvent cco = (IContainerConnectedEvent) o;
assertTrue(cco.getLocalContainerID().equals(client.getID()));
assertTrue(cco.getTargetID().equals(createServerID()));
}
use of org.eclipse.ecf.core.events.IContainerConnectedEvent in project ecf by eclipse.
the class ClientContainerConnectTest method createServerAndClients.
/*
* (non-Javadoc)
*
* @see org.eclipse.ecf.tests.connect.ContainerConnectTestCase#createServerAndClients()
*/
protected void createServerAndClients() throws Exception {
clientCount = 5;
super.createServerAndClients();
getServer().addListener(new IContainerListener() {
public void handleEvent(IContainerEvent event) {
if (event instanceof IContainerConnectedEvent)
serverConnectEvents.add(event);
if (event instanceof IContainerDisconnectedEvent)
serverDisconnectEvents.add(event);
}
});
}
Aggregations