use of org.eclipse.ecf.presence.chatroom.IChatRoomInfo in project ecf by eclipse.
the class AbstractChatRoomParticipantTest method setUp.
/*
* (non-Javadoc)
*
* @see org.eclipse.ecf.tests.presence.AbstractPresenceTestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
setClientCount(2);
clients = createClients();
IChatRoomManager chat0, chat1;
chat0 = getPresenceAdapter(0).getChatRoomManager();
chat1 = getPresenceAdapter(1).getChatRoomManager();
for (int i = 0; i < getClientCount(); i++) {
connectClient(i);
}
final IChatRoomInfo roomInfo0 = chat0.getChatRoomInfo(CHAT_ROOM_NAME);
if (roomInfo0 == null)
return;
chatRoomContainer0 = roomInfo0.createChatRoomContainer();
chatRoomContainer0.addChatRoomParticipantListener(participantListener0);
chatRoomContainer0.connect(roomInfo0.getRoomID(), null);
final IChatRoomInfo roomInfo1 = chat1.getChatRoomInfo(CHAT_ROOM_NAME);
chatRoomContainer1 = roomInfo1.createChatRoomContainer();
chatRoomContainer1.addChatRoomParticipantListener(participantListener1);
chatRoomContainer1.connect(roomInfo1.getRoomID(), null);
Thread.sleep(2000);
}
use of org.eclipse.ecf.presence.chatroom.IChatRoomInfo in project ecf by eclipse.
the class ChatRoomBot method connect.
public synchronized void connect() throws ECFException {
fireInitBot();
try {
Namespace namespace = null;
if (container == null) {
container = ContainerFactory.getDefault().createContainer(bot.getContainerFactoryName());
namespace = container.getConnectNamespace();
} else
// $NON-NLS-1$
throw new ContainerConnectException("Already connected");
targetID = IDFactory.getDefault().createID(namespace, bot.getConnectID());
IChatRoomManager manager = (IChatRoomManager) container.getAdapter(IChatRoomManager.class);
if (manager == null)
// $NON-NLS-1$
throw new ECFException("No chat room manager available");
firePreConnect();
String password = bot.getPassword();
IConnectContext context = (password == null) ? null : ConnectContextFactory.createPasswordConnectContext(password);
container.connect(targetID, context);
String[] roomNames = bot.getChatRooms();
String[] roomPasswords = bot.getChatRoomPasswords();
for (int i = 0; i < roomNames.length; i++) {
IChatRoomInfo room = manager.getChatRoomInfo(roomNames[i]);
roomContainer = room.createChatRoomContainer();
roomID = room.getRoomID();
firePreRoomConnect();
roomContainer.addMessageListener(this);
IConnectContext roomContext = (roomPasswords[i] == null) ? null : ConnectContextFactory.createPasswordConnectContext(roomPasswords[i]);
roomContainer.connect(roomID, roomContext);
}
} catch (ECFException e) {
if (container != null) {
if (container.getConnectedID() != null) {
container.disconnect();
}
container.dispose();
}
container = null;
throw e;
}
}
use of org.eclipse.ecf.presence.chatroom.IChatRoomInfo in project ecf by eclipse.
the class XMPPChatRoomManager method getChatRoomInfos.
public IChatRoomInfo[] getChatRoomInfos() {
final ID[] chatRooms = getChatRooms();
if (chatRooms == null)
return new IChatRoomInfo[0];
final IChatRoomInfo[] res = new IChatRoomInfo[chatRooms.length];
int count = 0;
for (int i = 0; i < chatRooms.length; i++) {
final IChatRoomInfo infoResult = getChatRoomInfo(chatRooms[i]);
if (infoResult != null) {
res[count++] = infoResult;
}
}
final IChatRoomInfo[] results = new IChatRoomInfo[count];
for (int i = 0; i < count; i++) {
results[i] = res[i];
}
return results;
}
use of org.eclipse.ecf.presence.chatroom.IChatRoomInfo in project ecf by eclipse.
the class XMPPChatRoomManager method getChatRoomInfo.
public IChatRoomInfo getChatRoomInfo(String roomname) {
try {
if (ecfConnection == null)
return null;
// Create roomid
final XMPPConnection conn = ecfConnection.getXMPPConnection();
final XMPPRoomID roomID = new XMPPRoomID(connectNamespace, conn, roomname);
final String mucName = roomID.getMucString();
final RoomInfo info = MultiUserChat.getRoomInfo(conn, mucName);
if (info != null) {
return new ECFRoomInfo(roomID, info, connectedID);
}
} catch (final Exception e) {
return null;
}
return null;
}
Aggregations