Search in sources :

Example 1 with IChannel

use of org.eclipse.ecf.datashare.IChannel in project ecf by eclipse.

the class NIODatashareContainer method createChannel.

public final IChannel createChannel(IChannelConfig newChannelConfig) throws ECFException {
    // $NON-NLS-1$
    Assert.isNotNull(newChannelConfig, "Channel config cannot be null");
    Assert.isNotNull(newChannelConfig.getID(), // $NON-NLS-1$
    "Channel config id cannot be null");
    IChannel channel = createNIOChannel(newChannelConfig);
    if (channel != null) {
        storeChannel(channel);
        fireChannelContainerActivatedEvent(newChannelConfig.getID());
    }
    return channel;
}
Also used : IChannel(org.eclipse.ecf.datashare.IChannel)

Example 2 with IChannel

use of org.eclipse.ecf.datashare.IChannel in project ecf by eclipse.

the class ChannelTest method testBiSendMessage.

public void testBiSendMessage() throws Exception {
    final IChannel ch0 = getChannelContainer(0).getChannel(channelID);
    final IChannel ch1 = getChannelContainer(1).getChannel(channelID);
    ID target1 = getClient(1).getConnectedID();
    ID target0 = getClient(0).getConnectedID();
    ch0.sendMessage(target1, new String("hello").getBytes());
    ch1.sendMessage(target0, new String("hello").getBytes());
    sleep(SLEEPTIME);
}
Also used : IChannel(org.eclipse.ecf.datashare.IChannel) ID(org.eclipse.ecf.core.identity.ID)

Example 3 with IChannel

use of org.eclipse.ecf.datashare.IChannel in project ecf by eclipse.

the class ChannelTest method testSendMessages.

public void testSendMessages() throws Exception {
    final IChannel ch0 = getChannelContainer(0).getChannel(channelID);
    ID target1 = getClient(1).getConnectedID();
    for (int i = 0; i < SEND_MESSAGE_COUNT; i++) {
        ch0.sendMessage(target1, new String("hello.  msg#=" + i).getBytes());
    }
    sleep(SLEEPTIME);
}
Also used : IChannel(org.eclipse.ecf.datashare.IChannel) ID(org.eclipse.ecf.core.identity.ID)

Example 4 with IChannel

use of org.eclipse.ecf.datashare.IChannel in project ecf by eclipse.

the class ScribbleClient method createChannel.

protected void createChannel() throws ECFException {
    // Get IChannelContainerAdapter adapter
    IChannelContainerAdapter channelContainer = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
    // Create channel ID with fixed name 'channel2'
    final ID channelID = IDFactory.getDefault().createID(channelContainer.getChannelNamespace(), CHANNEL_ID);
    // Setup listener so then when channelmessageevents are received that
    // they present in UI
    final IChannelListener channelListener = new IChannelListener() {

        public void handleChannelEvent(final IChannelEvent event) {
            if (event instanceof IChannelMessageEvent) {
                IChannelMessageEvent msg = (IChannelMessageEvent) event;
                scribbleView.handleDrawLine(msg.getData());
            }
        }
    };
    // Create new channel
    IChannel channel = channelContainer.createChannel(channelID, channelListener, new HashMap());
    // Set the view to use the given channel (for sending)
    scribbleView.setChannel(channel);
}
Also used : IChannelListener(org.eclipse.ecf.datashare.IChannelListener) IChannel(org.eclipse.ecf.datashare.IChannel) IChannelEvent(org.eclipse.ecf.datashare.events.IChannelEvent) HashMap(java.util.HashMap) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) ID(org.eclipse.ecf.core.identity.ID) IChannelMessageEvent(org.eclipse.ecf.datashare.events.IChannelMessageEvent)

Example 5 with IChannel

use of org.eclipse.ecf.datashare.IChannel in project ecf by eclipse.

the class ChannelTest method testSender.

public void testSender() throws Exception {
    final IChannelContainerAdapter senderContainer = getChannelContainer(0);
    final IChannel sender = senderContainer.getChannel(getNewID(CHANNEL_NAME));
    assertNotNull(sender);
    sender.sendMessage(new String("hello").getBytes());
    sleep(3000);
    for (int i = 1; i < getClientCount(); i++) {
        assertNotNull(messageEvents.get(getContainerID(i)));
    }
}
Also used : IChannel(org.eclipse.ecf.datashare.IChannel) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter)

Aggregations

IChannel (org.eclipse.ecf.datashare.IChannel)15 ID (org.eclipse.ecf.core.identity.ID)8 IChannelContainerAdapter (org.eclipse.ecf.datashare.IChannelContainerAdapter)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Iterator (java.util.Iterator)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 SocketChannel (java.nio.channels.SocketChannel)1 HashMap (java.util.HashMap)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Job (org.eclipse.core.runtime.jobs.Job)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IChannelListener (org.eclipse.ecf.datashare.IChannelListener)1