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;
}
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);
}
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);
}
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);
}
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)));
}
}
Aggregations