Search in sources :

Example 6 with IContainerConnectedEvent

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;
        }
    });
}
Also used : IEventProcessor(org.eclipse.ecf.core.util.IEventProcessor) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent) Event(org.eclipse.ecf.core.util.Event) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent)

Example 7 with IContainerConnectedEvent

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;
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) IContainerListener(org.eclipse.ecf.core.IContainerListener) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent) IDCreateErrorDialog(org.eclipse.ecf.ui.dialogs.IDCreateErrorDialog) IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) ITypingMessageEvent(org.eclipse.ecf.presence.im.ITypingMessageEvent) AsynchContainerConnectAction(org.eclipse.ecf.ui.actions.AsynchContainerConnectAction) IChatManager(org.eclipse.ecf.presence.im.IChatManager)

Example 8 with IContainerConnectedEvent

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");
}
Also used : IEventProcessor(org.eclipse.ecf.core.util.IEventProcessor) ISharedObjectActivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent) ISharedObjectActivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent) Event(org.eclipse.ecf.core.util.Event) ID(org.eclipse.ecf.core.identity.ID) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent)

Example 9 with IContainerConnectedEvent

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()));
}
Also used : IContainer(org.eclipse.ecf.core.IContainer) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent)

Example 10 with IContainerConnectedEvent

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);
        }
    });
}
Also used : IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) IContainerDisconnectedEvent(org.eclipse.ecf.core.events.IContainerDisconnectedEvent) IContainerListener(org.eclipse.ecf.core.IContainerListener) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent)

Aggregations

IContainerConnectedEvent (org.eclipse.ecf.core.events.IContainerConnectedEvent)12 IContainerDisconnectedEvent (org.eclipse.ecf.core.events.IContainerDisconnectedEvent)6 ISharedObjectActivatedEvent (org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent)5 IContainerEvent (org.eclipse.ecf.core.events.IContainerEvent)4 ISharedObjectDeactivatedEvent (org.eclipse.ecf.core.sharedobject.events.ISharedObjectDeactivatedEvent)4 ISharedObjectMessageEvent (org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageEvent)4 IContainerListener (org.eclipse.ecf.core.IContainerListener)3 IContainer (org.eclipse.ecf.core.IContainer)2 ID (org.eclipse.ecf.core.identity.ID)2 Event (org.eclipse.ecf.core.util.Event)2 IEventProcessor (org.eclipse.ecf.core.util.IEventProcessor)2 AsynchContainerConnectAction (org.eclipse.ecf.ui.actions.AsynchContainerConnectAction)2 IDCreateErrorDialog (org.eclipse.ecf.ui.dialogs.IDCreateErrorDialog)2 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 IIMMessageEvent (org.eclipse.ecf.presence.IIMMessageEvent)1 IIMMessageListener (org.eclipse.ecf.presence.IIMMessageListener)1 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)1 IChatManager (org.eclipse.ecf.presence.im.IChatManager)1 IChatMessageEvent (org.eclipse.ecf.presence.im.IChatMessageEvent)1 ITypingMessageEvent (org.eclipse.ecf.presence.im.ITypingMessageEvent)1