Search in sources :

Example 11 with IChannelEvent

use of org.eclipse.ecf.datashare.events.IChannelEvent in project ecf by eclipse.

the class DsClient1 method createChannel.

protected IChannel createChannel(IContainer container) throws ECFException {
    IChannelContainerAdapter channelContainer = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
    if (channelContainer == null)
        throw new NullPointerException("cannot get channel container adapter");
    ID channelID = IDFactory.getDefault().createID(channelContainer.getChannelNamespace(), "channel1");
    IChannelListener channelListener = new IChannelListener() {

        public void handleChannelEvent(IChannelEvent event) {
            System.out.println("handleChannelEvent(" + event + ")");
        }
    };
    return channelContainer.createChannel(channelID, channelListener, new HashMap());
}
Also used : IChannelListener(org.eclipse.ecf.datashare.IChannelListener) IChannelEvent(org.eclipse.ecf.datashare.events.IChannelEvent) HashMap(java.util.HashMap) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) ID(org.eclipse.ecf.core.identity.ID)

Example 12 with IChannelEvent

use of org.eclipse.ecf.datashare.events.IChannelEvent in project ecf by eclipse.

the class DatashareManagerApplication method createChannelListener.

/**
 * Create a channel listener that simply prints out messages to System.out
 */
protected IChannelListener createChannelListener() {
    return new IChannelListener() {

        public void handleChannelEvent(IChannelEvent event) {
            if (event instanceof IChannelMessageEvent) {
                IChannelMessageEvent messageEvent = (IChannelMessageEvent) event;
                // print to system out
                System.out.println("Received message from " + messageEvent.getFromContainerID().getName() + "\n\tmessage=" + new String(messageEvent.getData()));
            }
        }
    };
}
Also used : IChannelListener(org.eclipse.ecf.datashare.IChannelListener) IChannelEvent(org.eclipse.ecf.datashare.events.IChannelEvent) IChannelMessageEvent(org.eclipse.ecf.datashare.events.IChannelMessageEvent)

Aggregations

IChannelListener (org.eclipse.ecf.datashare.IChannelListener)12 IChannelEvent (org.eclipse.ecf.datashare.events.IChannelEvent)12 IChannelMessageEvent (org.eclipse.ecf.datashare.events.IChannelMessageEvent)8 ID (org.eclipse.ecf.core.identity.ID)6 HashMap (java.util.HashMap)4 InetSocketAddress (java.net.InetSocketAddress)3 IChannelContainerAdapter (org.eclipse.ecf.datashare.IChannelContainerAdapter)3 File (java.io.File)1 List (java.util.List)1 ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)1 StringID (org.eclipse.ecf.core.identity.StringID)1 BaseChannelConfig (org.eclipse.ecf.datashare.BaseChannelConfig)1 IChannel (org.eclipse.ecf.datashare.IChannel)1 IChannelConfig (org.eclipse.ecf.datashare.IChannelConfig)1 IChannelConnectEvent (org.eclipse.ecf.datashare.events.IChannelConnectEvent)1 IChannelDisconnectEvent (org.eclipse.ecf.datashare.events.IChannelDisconnectEvent)1 IMergeableChannel (org.eclipse.ecf.datashare.mergeable.IMergeableChannel)1 IMergeableChannelContainerAdapter (org.eclipse.ecf.datashare.mergeable.IMergeableChannelContainerAdapter)1 RssFeed (org.eclipse.higgins.rsse.RssFeed)1 RssItem (org.eclipse.higgins.rsse.RssItem)1