Search in sources :

Example 51 with ID

use of org.eclipse.ecf.core.identity.ID 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 52 with ID

use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.

the class NIODatashareTest method testChannelDisconnectEvent.

public void testChannelDisconnectEvent() throws Exception {
    final ID[] eventIds = new ID[2];
    channelA = createChannel(channelContainerA, new IChannelListener() {

        public void handleChannelEvent(IChannelEvent e) {
            if (e instanceof IChannelDisconnectEvent) {
                IChannelDisconnectEvent event = (IChannelDisconnectEvent) e;
                eventIds[0] = event.getChannelID();
                eventIds[1] = event.getTargetID();
            }
        }
    });
    containerA.disconnect();
    assertEquals(channelA.getID(), eventIds[0]);
    // technically, getConnectedID() should return null when a container has
    // disconnected, but anyway...
    assertEquals(containerA.getConnectedID(), eventIds[1]);
}
Also used : IChannelListener(org.eclipse.ecf.datashare.IChannelListener) IChannelEvent(org.eclipse.ecf.datashare.events.IChannelEvent) IChannelDisconnectEvent(org.eclipse.ecf.datashare.events.IChannelDisconnectEvent) ID(org.eclipse.ecf.core.identity.ID)

Example 53 with ID

use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.

the class FQIDTest method testFQID3.

public void testFQID3() throws Exception {
    final ID local = IDFactory.getDefault().createID(namespace, "foobar@ecf.eclipse.org:5333/myresource");
    assertNotNull(local);
    final IFQID localfqid = (IFQID) local.getAdapter(IFQID.class);
    assertNotNull(localfqid);
    assertNotNull(localfqid.getFQName());
    assertNotNull(localfqid.getResourceName());
    final IFQID idfqid = (IFQID) id3.getAdapter(IFQID.class);
    assertTrue(!local.equals(id3));
    assertTrue(!localfqid.getFQName().equals(idfqid.getFQName()));
    assertTrue(!localfqid.getResourceName().equals(idfqid.getResourceName()));
}
Also used : IFQID(org.eclipse.ecf.presence.IFQID) ID(org.eclipse.ecf.core.identity.ID) IFQID(org.eclipse.ecf.presence.IFQID)

Example 54 with ID

use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.

the class FQIDTest method testFQID.

public void testFQID() throws Exception {
    final ID local = IDFactory.getDefault().createID(namespace, "foobar@ecf.eclipse.org:5333/myresource");
    assertNotNull(local);
    final IFQID localfqid = (IFQID) local.getAdapter(IFQID.class);
    assertNotNull(localfqid);
    assertNotNull(localfqid.getFQName());
    assertNotNull(localfqid.getResourceName());
}
Also used : IFQID(org.eclipse.ecf.presence.IFQID) ID(org.eclipse.ecf.core.identity.ID) IFQID(org.eclipse.ecf.presence.IFQID)

Example 55 with ID

use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.

the class DsClient2 method createChannel.

protected IChannel createChannel(IContainer container) throws ECFException {
    // Get IChannelContainerAdapter adapter
    IChannelContainerAdapter channelContainer = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
    // Check it's valid, throw if not
    if (channelContainer == null)
        throw new NullPointerException("cannot get channel container adapter");
    // Create channel ID with fixed name 'channel2'
    final ID channelID = IDFactory.getDefault().createID(channelContainer.getChannelNamespace(), "channel2");
    // 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;
                showMessageInUI(new String(msg.getData()));
            } else
                System.out.println("got channel event " + event);
        }
    };
    // Create channel config information
    IChannelConfig config = new BaseChannelConfig(channelID, channelListener, new HashMap());
    // Create and return new channel
    return channelContainer.createChannel(config);
}
Also used : IChannelConfig(org.eclipse.ecf.datashare.IChannelConfig) IChannelListener(org.eclipse.ecf.datashare.IChannelListener) IChannelEvent(org.eclipse.ecf.datashare.events.IChannelEvent) BaseChannelConfig(org.eclipse.ecf.datashare.BaseChannelConfig) HashMap(java.util.HashMap) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) ID(org.eclipse.ecf.core.identity.ID) IChannelMessageEvent(org.eclipse.ecf.datashare.events.IChannelMessageEvent)

Aggregations

ID (org.eclipse.ecf.core.identity.ID)256 IContainer (org.eclipse.ecf.core.IContainer)29 IOException (java.io.IOException)19 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)18 UUID (java.util.UUID)17 HashMap (java.util.HashMap)12 ArrayList (java.util.ArrayList)11 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)11 GUID (org.eclipse.ecf.core.identity.GUID)11 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)11 XMPPRoomID (org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID)11 Namespace (org.eclipse.ecf.core.identity.Namespace)10 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)10 Map (java.util.Map)9 Matcher (java.util.regex.Matcher)9 ECFException (org.eclipse.ecf.core.util.ECFException)9 List (java.util.List)8 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)8 IChannel (org.eclipse.ecf.datashare.IChannel)8 Iterator (java.util.Iterator)7