Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] Radical proposal

ECF is cool, no doubt about that. But the API is, IMHO, a bit verbose
and complex. I made a simple xmpp client that joined a chat room and
said hi. Here are three pieces of code. The first is using just the
Smack library. The second uses ECF. The third is how I would like it in
ECF.

<code>

Smack
-----
XMPPConnection conn = new XMPPConnection("jabber.org");
conn.login("tim", "password");
MultiUserChat chat = new MultiUserChat(conn, "timtest@xxxxxxxxxxxxxxxxxxxxx");
chat.join("santa");
chat.sendMessage("howdy");


ECF
---
IContainer client = ContainerFactory.getDefault().createContainer("ecf.xmpp.smack");
ID server = IDFactory.getDefault().createID(client.getConnectNamespace(), "tim@xxxxxxxxxx");
IPresenceContainer presence = (IPresenceContainer) client.getAdapter(IPresenceContainer.class);

client.connect(server, ConnectContextFactory.createPasswordConnectContext("password"));

IChatRoomManager chatmanager = presence.getChatRoomManager();
IChatRoomContainer chatroom = chatmanager.createChatRoomContainer();
ID roomID = IDFactory.getDefault().createID(chatroom.getConnectNamespace(), new Object[] {"tim","jabber.org",null,"timtest","santa"});
chatroom.connect(roomID, null);
IChatMessageSender chatSender = chatroom.getChatMessageSender();
chatSender.sendMessage("howdy");


A not so complex ECF
--------------------
IContainer client = ContainerFactory.createContainer("ecf.xmpp.smack");

ID server = client.createID("jabber.org");
client.connect(server, new Auth("tim", "password"));

IChatRoomContainer chatRoom = client.getAdapter(IChatRoomManager.class).join("timtest");
chatRoom.sendMessage("howdy");

</code>

Note that I'm no well-known super architect and don't know the ins
and outs of ECF, so this might be crazy. What are your reactions?

Tim


Back to the top