Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2006-05-28 06:12:33 +0000
committerslewis2006-05-28 06:12:33 +0000
commit0744c59ecef1d104a7eec7c1c70b29c691dabf48 (patch)
tree5251fa990c4c15ea523258f96de3d4bac2b924a9
parent62c88c878f14bd88bf6008ad02a4fe8ad2b3080e (diff)
downloadorg.eclipse.ecf-0744c59ecef1d104a7eec7c1c70b29c691dabf48.tar.gz
org.eclipse.ecf-0744c59ecef1d104a7eec7c1c70b29c691dabf48.tar.xz
org.eclipse.ecf-0744c59ecef1d104a7eec7c1c70b29c691dabf48.zip
Refactor of XMPPChatClient for generality and simplicity
-rw-r--r--examples/bundles/org.eclipse.ecf.example.clients/src/org/eclipse/ecf/example/clients/XMPPChatClient.java29
1 files changed, 23 insertions, 6 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.clients/src/org/eclipse/ecf/example/clients/XMPPChatClient.java b/examples/bundles/org.eclipse.ecf.example.clients/src/org/eclipse/ecf/example/clients/XMPPChatClient.java
index 3783cb62d..2f85f487d 100644
--- a/examples/bundles/org.eclipse.ecf.example.clients/src/org/eclipse/ecf/example/clients/XMPPChatClient.java
+++ b/examples/bundles/org.eclipse.ecf.example.clients/src/org/eclipse/ecf/example/clients/XMPPChatClient.java
@@ -42,17 +42,23 @@ public class XMPPChatClient {
public XMPPChatClient() {
this(null);
}
-
public XMPPChatClient(IMessageReceiver receiver) {
super();
this.receiver = receiver;
}
- public void connect(String account, String password) throws ECFException {
+ protected IContainer createContainer() throws ECFException {
// Create container
container = ContainerFactory.getDefault().createContainer(CONTAINER_TYPE);
namespace = container.getConnectNamespace();
- // create target id
- ID targetID = IDFactory.getDefault().createID(namespace, account);
+ return container;
+ }
+ protected IContainer getContainer() {
+ return container;
+ }
+ protected Namespace getNamespace() {
+ return namespace;
+ }
+ protected void setupPresenceAdapter() {
// Get presence adapter off of container
presence = (IPresenceContainer) container
.getAdapter(IPresenceContainer.class);
@@ -64,9 +70,20 @@ public class XMPPChatClient {
receiver.handleMessage(fromID.getName(), messageBody);
}
});
- //
+ }
+ protected IPresenceContainer getPresenceContainer() {
+ return presence;
+ }
+ protected IMessageSender getMessageSender() {
+ return sender;
+ }
+ public void connect(String account, String password) throws ECFException {
+ createContainer();
+ setupPresenceAdapter();
+ // create target id
+ ID targetID = IDFactory.getDefault().createID(getNamespace(), account);
// Now connect
- container.connect(targetID,ConnectContextFactory.createPasswordConnectContext(password));
+ getContainer().connect(targetID,ConnectContextFactory.createPasswordConnectContext(password));
// Get a local ID for user account
userID = getID(account);
}

Back to the top