Package org.eclipse.ecf.example.clients

Examples of org.eclipse.ecf.example.clients.XMPPChatClient


    String message = null;
    if (originalArgs.length > 3)
      message = originalArgs[3];

    // Create client
    XMPPChatClient client = new XMPPChatClient(this, this);

    // connect
    client.connect(originalArgs[0], originalArgs[1]);

    // Wait for 5s for the roster/presence information to be received
    final Object lock = new Object();
    synchronized (lock) {
      lock.wait(5000);
    }

    // Get desired user ID from rosterUsers map. This is just looking for a
    // user that's active and on our contacts list
    ID targetID = (ID) rosterUsers.get(originalArgs[2]);
    if (targetID == null) {
      System.out
          .println("target user="
              + originalArgs[2]
              + " is not on active on your contacts list.  Cannot send message to this user");
      return new Integer(0);
    }
    // Construct message
    String msgToSend = (message == null) ? "Hi, I'm an ECF chat robot."
        : message;
    System.out.println("ECF chat robot example sending to targetAccount="
        + originalArgs[2] + " message=" + msgToSend);

    // Send chat message to targetID
    client.sendChat(targetID, msgToSend);

    // Get shared object container adapter
    ISharedObjectContainer socontainer = (ISharedObjectContainer) client
        .getContainer().getAdapter(ISharedObjectContainer.class);
    // Create and add shared object to container
    TrivialSharedObject sharedObject = new TrivialSharedObject();
    socontainer.getSharedObjectManager().addSharedObject(
        IDFactory.getDefault().createStringID(
            TrivialSharedObject.class.getName()), sharedObject,
        null);

    // Send messages via shared object...and wait a short while before sending the next one
    int count = 0;
    synchronized (lock) {
      while (count++ < 5) {
        // Send shared object message
        sharedObject.sendMessageTo(targetID, "hello from "
            + originalArgs[0]+" via shared object");
        lock.wait(5000);
      }

    }

    // Close up nicely
    client.close();
    return IApplication.EXIT_OK;
  }
View Full Code Here


    }
    String message = null;
    if (originalArgs.length > 3) message = originalArgs[3];
   
    // Create client
    XMPPChatClient client = new XMPPChatClient(this,this);
    // connect
    client.connect(originalArgs[0], originalArgs[1]);
   
    // Wait for 5s for the roster/presence information to be received
    final Object lock = new Object();
    synchronized (lock) {
      lock.wait(5000);
    }
   
    // Get desired user ID from rosterUsers map.  This is just looking for a user that's active and on our contacts list
    ID targetID = (ID) rosterUsers.get(originalArgs[2]);
    if (targetID == null) {
      System.out.println("target user="+originalArgs[2]+" is not on active on your contacts list.  Cannot send message to this user");
      return new Integer(0);
    }
    // Construct message
    String msgToSend = (message==null)?"Hi, I'm an ECF chat robot.":message;
    System.out.println("ECF chat robot example sending to targetAccount=" + originalArgs[2] + " message="+msgToSend);
   
    // Send message to targetID
    client.sendChat(targetID, msgToSend);

    // Close up nicely and return
    client.close();
    return IApplication.EXIT_OK;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.example.clients.XMPPChatClient

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.