Package org.eclipse.ecf.core.identity

Examples of org.eclipse.ecf.core.identity.ID


  protected void disconnect(Throwable exception) {
    synchronized (getConnectLock()) {
      // If we are currently connected then get connection lock and send
      // disconnect message
      if (isConnected()) {
        final ID groupID = getConnectedID();
        if (exception == null)
          fireContainerEvent(new ContainerDisconnectingEvent(this.getID(), groupID));
        synchronized (connection) {
          try {
            connection.sendSynch(groupID, serialize(ContainerMessage.createLeaveGroupMessage(getID(), groupID, getNextSequenceNumber(), getLeaveData(groupID))));
View Full Code Here


      throw new ConnectException("Container not connected"); //$NON-NLS-1$
  }

  protected ID handleConnectResponse(ID orginalTarget, Object serverData) throws Exception {
    final ContainerMessage aPacket = (ContainerMessage) serverData;
    final ID fromID = aPacket.getFromContainerID();
    Assert.isNotNull(fromID, "fromID cannot be null"); //$NON-NLS-1$
    final ContainerMessage.ViewChangeMessage viewChangeMessage = (ContainerMessage.ViewChangeMessage) aPacket.getData();
    // If it's not an add message then we've been refused. Get exception
    // info from viewChangeMessage and
    // throw if there
    if (!viewChangeMessage.isAdd()) {
      // We were refused by server...so we retrieve data and throw
      final Object data = viewChangeMessage.getData();
      if (data != null && data instanceof Exception)
        throw (Exception) data;
      throw new InvalidObjectException("Invalid server response"); //$NON-NLS-1$
    }
    // Otherwise everything is OK to this point and we get the group member
    // IDs from server
    final ID[] ids = viewChangeMessage.getChangeIDs();
    Assert.isNotNull(ids, "view change ids cannot be null"); //$NON-NLS-1$
    for (int i = 0; i < ids.length; i++) {
      final ID id = ids[i];
      if (id != null && !id.equals(getID()))
        addNewRemoteMember(id, null);
    }
    return fromID;
  }
View Full Code Here

    IServiceInfo serviceInfo = DiscoveryPropertyTesterUtil
        .getIServiceInfoReceiver(receiver);
    final String connectNamespace = getConnectNamespace(serviceInfo);
    final String connectId = getConnectID(serviceInfo);
    try {
      final ID createConnectId = IDFactory.getDefault().createID(
          connectNamespace, connectId);
      return (getContainerByConnectID(createConnectId) != null);
    } catch (IDCreateException e) {
      // Trace.trace(...);
      return false;
View Full Code Here

    final IContainer[] containers = containerManager.getAllContainers();
    if (containers == null) {
      return null;
    }
    for (int i = 0; i < containers.length; i++) {
      ID connectedId = containers[i].getConnectedID();
      if (connectedId != null && connectedId.equals(connectID)) {
        return containers[i];
      }
    }
    return null;
  }
View Full Code Here

      e.printStackTrace();
    }
  }

  public void handleRoomMessage(IChatRoomMessage message) {
    ID fromID = message.getFromID();
    String name = fromID.getName();
    if (name.charAt(0) == '#' || name.equals(botName)) { // skip messages
      // from the
      // channel or
      // self
      return;
View Full Code Here

    this.container = container;

    container.addListener(new IContainerListener() {
      public void handleEvent(IContainerEvent event) {
        if (event instanceof IContainerConnectedEvent) {
          ID id = ((IContainerConnectedEvent) event).getTargetID();
          fireChannelConnectedEvent(id);
        } else if (event instanceof IContainerDisconnectedEvent) {
          ID id = ((IContainerDisconnectedEvent) event).getTargetID();
          fireChannelDisconnectedEvent(id);

          disconnect();
        } else if (event instanceof IContainerDisposeEvent) {
          // also invoke disconnect() here in case a disconnection
View Full Code Here

    // nothing to do
  }

  public void preChatRoomConnect(IChatRoomContainer roomContainer, ID roomID) {
    // retrieve our name
    ID connectedID = container.getConnectedID();
    botName = connectedID.getName();
    IChatID chatID = (IChatID) connectedID.getAdapter(IChatID.class);
    if (chatID != null) {
      botName = chatID.getUsername();
    }
   
    messageSenders.put(roomID, roomContainer.getChatRoomMessageSender());
View Full Code Here

    // read in the response
    ByteArrayInputStream bais = new ByteArrayInputStream(message);
    ObjectInputStream ois = new ObjectInputStream(bais);

    // first response should be the channel id
    ID channelId = (ID) ois.readObject();

    synchronized (channels) {
      // retrieve the channel that corresponds to that id
      IChannel channel = getChannel(channelId);
      if (channel == null) {
        // can't find a channel that corresponds to the id, close the
        // socket
        Util.closeChannel(socketChannel);
      } else {
        // open another ObjectInputStream because each object is
        // serialized separately
        ois = new ObjectInputStream(bais);

        // next id is the id of the remote user
        ID peerId = (ID) ois.readObject();

        // store the peer id and the corresponding socket in the
        // retrieved NIO channel
        NIOChannel datashare = (NIOChannel) channel;
        datashare.put(peerId, socketChannel);
View Full Code Here

    }
  }

  protected ISharedObjectContainer createClient() throws Exception {
    // Make identity instance for the new container
    ID newContainerID = IDFactory.getDefault().createGUID();
    ISharedObjectContainer result = SharedObjectContainerFactory.getDefault().createSharedObjectContainer(contd, new Object[] {newContainerID, new Integer(DEFAULT_TIMEOUT)});
    return result;
  }
View Full Code Here

   */
  public static void main(String[] args) throws Exception {
    ClientApplication st = new ClientApplication();
    st.init(args);
    // Get server id to join
    ID serverID = IDFactory.getDefault().createStringID(st.serverName);
    st.connect(serverID);
    st.createSharedObjects();
    System.out.println("Waiting " + DEFAULT_WAITTIME + " ms..."); //$NON-NLS-1$ //$NON-NLS-2$
    Thread.sleep(DEFAULT_WAITTIME);
    st.removeSharedObjects();
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.core.identity.ID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.