Search in sources :

Example 16 with IChannelListener

use of org.eclipse.ecf.datashare.IChannelListener 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)16 IChannelEvent (org.eclipse.ecf.datashare.events.IChannelEvent)12 IChannelMessageEvent (org.eclipse.ecf.datashare.events.IChannelMessageEvent)8 ID (org.eclipse.ecf.core.identity.ID)7 HashMap (java.util.HashMap)5 InetSocketAddress (java.net.InetSocketAddress)3 IChannelContainerAdapter (org.eclipse.ecf.datashare.IChannelContainerAdapter)3 StringID (org.eclipse.ecf.core.identity.StringID)2 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)2 SharedObjectCreateException (org.eclipse.ecf.core.sharedobject.SharedObjectCreateException)2 IMergeableChannel (org.eclipse.ecf.datashare.mergeable.IMergeableChannel)2 File (java.io.File)1 IOException (java.io.IOException)1 Constructor (java.lang.reflect.Constructor)1 List (java.util.List)1 Map (java.util.Map)1 ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 SharedObjectDescription (org.eclipse.ecf.core.sharedobject.SharedObjectDescription)1 SharedObjectTypeDescription (org.eclipse.ecf.core.sharedobject.SharedObjectTypeDescription)1