summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-08 08:20:11 (EDT)
committerEike Stepper2007-10-08 08:20:11 (EDT)
commit4f8972b433a7a4cba71c7fcd9c9aa92b858880b4 (patch)
tree7a0f074327caeb20406795ed5ba04225ab2b0182
parent3f712591aa72eb74d908e2e877a8935af63705fc (diff)
downloadcdo-4f8972b433a7a4cba71c7fcd9c9aa92b858880b4.zip
cdo-4f8972b433a7a4cba71c7fcd9c9aa92b858880b4.tar.gz
cdo-4f8972b433a7a4cba71c7fcd9c9aa92b858880b4.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java21
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java27
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java16
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java2
5 files changed, 50 insertions, 20 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
index 308fbd1..1fc0fa4 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
@@ -92,6 +92,8 @@ public class BuddiesView extends ContainerView implements IListener
disconnectAction.setEnabled(true);
availableAction.setEnabled(true);
availableAction.setChecked(session.getSelf().getState() == IBuddy.State.AVAILABLE);
+ lonesomeAction.setEnabled(true);
+ lonesomeAction.setChecked(session.getSelf().getState() == IBuddy.State.LONESOME);
awayAction.setEnabled(true);
awayAction.setChecked(session.getSelf().getState() == IBuddy.State.AWAY);
doNotDisturbAction.setEnabled(true);
@@ -131,6 +133,8 @@ public class BuddiesView extends ContainerView implements IListener
disconnectAction.setEnabled(false);
availableAction.setEnabled(false);
availableAction.setChecked(false);
+ lonesomeAction.setEnabled(false);
+ lonesomeAction.setChecked(false);
awayAction.setEnabled(false);
awayAction.setChecked(false);
doNotDisturbAction.setEnabled(false);
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java
index ee52e9d..6d90cfc 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java
@@ -17,6 +17,7 @@ import org.eclipse.net4j.internal.buddies.Buddy;
import org.eclipse.net4j.internal.buddies.BuddySession;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.signal.SignalReactor;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
/**
* @author Eike Stepper
@@ -49,11 +50,23 @@ public class BuddiesClientProtocol extends SignalProtocol
@Override
protected void stateChanged(String userID, State state)
{
- BuddySession session = (BuddySession)getInfraStructure();
- Buddy buddy = (Buddy)session.getBuddies().get(userID);
- if (buddy != null)
+ for (int i = 0; i < 50; i++)
{
- buddy.setState(state);
+ BuddySession session = (BuddySession)getProtocol().getInfraStructure();
+ if (session == null)
+ {
+ ConcurrencyUtil.sleep(100);
+ }
+ else
+ {
+ Buddy buddy = (Buddy)session.getBuddies().get(userID);
+ if (buddy != null)
+ {
+ buddy.setState(state);
+ }
+
+ break;
+ }
}
}
};
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java
index 04f1824..71b86c7 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java
@@ -13,6 +13,7 @@ package org.eclipse.net4j.internal.buddies.protocol;
import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
import org.eclipse.net4j.internal.buddies.BuddySession;
import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import java.io.IOException;
@@ -36,18 +37,18 @@ public class BuddyAddedIndication extends Indication
protected void indicating(ExtendedDataInputStream in) throws IOException
{
String buddy = in.readString();
- // for (int i = 0; i < 5; i++)
- // {
- BuddySession session = (BuddySession)getProtocol().getInfraStructure();
- // if (session == null)
- // {
- // ConcurrencyUtil.sleep(1000);
- // }
- // else
- // {
- session.buddyAdded(buddy);
- // break;
- // }
- // }
+ for (int i = 0; i < 50; i++)
+ {
+ BuddySession session = (BuddySession)getProtocol().getInfraStructure();
+ if (session == null)
+ {
+ ConcurrencyUtil.sleep(100);
+ }
+ else
+ {
+ session.buddyAdded(buddy);
+ break;
+ }
+ }
}
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java
index edc1bf7..2be0d46 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java
@@ -13,6 +13,7 @@ package org.eclipse.net4j.internal.buddies.protocol;
import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
import org.eclipse.net4j.internal.buddies.BuddySession;
import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import java.io.IOException;
@@ -36,7 +37,18 @@ public class BuddyRemovedIndication extends Indication
protected void indicating(ExtendedDataInputStream in) throws IOException
{
String buddy = in.readString();
- BuddySession session = (BuddySession)getProtocol().getInfraStructure();
- session.buddyRemoved(buddy);
+ for (int i = 0; i < 50; i++)
+ {
+ BuddySession session = (BuddySession)getProtocol().getInfraStructure();
+ if (session == null)
+ {
+ ConcurrencyUtil.sleep(100);
+ }
+ else
+ {
+ session.buddyRemoved(buddy);
+ break;
+ }
+ }
}
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java
index 5a8f219..ddda00a 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java
@@ -62,6 +62,7 @@ public class OpenSessionRequest extends RequestWithConfirmation<IBuddySession>
}
BuddySession session = new BuddySession(getProtocol().getChannel());
+ getProtocol().setInfraStructure(session);
session.setSelf(account);
int size = in.readInt();
@@ -70,7 +71,6 @@ public class OpenSessionRequest extends RequestWithConfirmation<IBuddySession>
session.buddyAdded(in.readString());
}
- getProtocol().setInfraStructure(session);
LifecycleUtil.activate(session);
return session;
}