use of org.eclipse.ecf.datashare.IChannelListener in project ecf by eclipse.
the class NIODatashareTest method testChannelConnectEvent.
public void testChannelConnectEvent() throws Exception {
final ID[] eventIds = new ID[2];
channelA = createChannel(channelContainerA, new IChannelListener() {
public void handleChannelEvent(IChannelEvent e) {
if (e instanceof IChannelConnectEvent) {
IChannelConnectEvent event = (IChannelConnectEvent) e;
eventIds[0] = event.getChannelID();
eventIds[1] = event.getTargetID();
}
}
});
containerA.connect(null, null);
assertEquals(channelA.getID(), eventIds[0]);
assertEquals(containerA.getConnectedID(), eventIds[1]);
}
use of org.eclipse.ecf.datashare.IChannelListener in project ecf by eclipse.
the class NIODatashareTest method testOneWaySend16k.
public void testOneWaySend16k() throws Exception {
final byte[][] actual = new byte[1][];
channelA = createChannel(channelContainerA);
int targetPort = channelA.getPort();
channelB = createChannel(channelContainerB, new IChannelListener() {
public void handleChannelEvent(IChannelEvent event) {
if (event instanceof IChannelMessageEvent) {
actual[0] = ((IChannelMessageEvent) event).getData();
synchronized (waitObject) {
waitObject.notify();
}
}
}
});
byte[] expected = new byte[16384];
for (int i = 0; i < expected.length; i++) {
expected[i] = (byte) (i % 128);
}
channelA.sendMessage(containerB.getConnectedID(), expected);
channelContainerB.enqueue(new InetSocketAddress(LOCALHOST, targetPort));
waitForCompletion(10000);
assertEquals(expected, actual[0]);
}
use of org.eclipse.ecf.datashare.IChannelListener 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());
}
use of org.eclipse.ecf.datashare.IChannelListener in project ecf by eclipse.
the class NIOChannel method setListener.
public IChannelListener setListener(IChannelListener listener) {
IChannelListener previous = this.listener;
this.listener = listener;
return previous;
}
use of org.eclipse.ecf.datashare.IChannelListener in project ecf by eclipse.
the class AbstractDatashareApplication method createChannel.
protected void createChannel() throws ECFException {
// Get datashare adapter from new container
datashareAdapter = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
// Create channel listener for channel to be created
IChannelListener channelListener = createChannelListener();
// Create a channel with given channel listener
testChannel = datashareAdapter.createChannel(IDFactory.getDefault().createStringID(Activator.class.getName()), channelListener, null);
}
Aggregations