use of org.eclipse.ecf.example.clients.XMPPChatRoomClient in project ecf by eclipse.
the class ChatRoomRobotApplication method start.
public Object start(IApplicationContext context) throws Exception {
// process program arguments
String[] originalArgs = (String[]) context.getArguments().get("application.args");
if (originalArgs.length < 4) {
System.out.println("Parameters: <senderAccount> <senderPassword> <chatroomname>. e.g. sender@gmail.com senderpassword mychatroom");
return new Integer(-1);
}
senderAccount = originalArgs[0];
// Create client
final XMPPChatRoomClient client = new XMPPChatRoomClient(this);
// connect to senderAccount using senderPassword
client.connect(senderAccount, originalArgs[1]);
// get chat room
final IChatRoomContainer chatRoomContainer = client.createChatRoom(originalArgs[2]);
// join/connect to chat room
chatRoomContainer.connect(client.getChatRoomInfo().getRoomID(), null);
System.out.println("ECF chat room robot sender=" + senderAccount + " Connected to room: " + client.getChatRoomInfo().getRoomID().getName());
// Add message listener to chat room
chatRoomContainer.addMessageListener(this);
// Get chat room message sender
sender = chatRoomContainer.getChatRoomMessageSender();
sender.sendMessage("Hi, I'm a robot. To get rid of me, send me a direct message.");
synchronized (lock) {
while (!done) {
lock.wait();
}
}
return IApplication.EXIT_OK;
}
Aggregations