summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-09 08:22:16 (EDT)
committerEike Stepper2007-10-09 08:22:16 (EDT)
commit78d72482bcfb1d30bb48000d57189fabc0fedc35 (patch)
tree6c1aca0c721cb2ac93649c7862f740a5310195e9
parent950db174d7800e51f6582579fc7a406b3a7c7473 (diff)
downloadcdo-78d72482bcfb1d30bb48000d57189fabc0fedc35.zip
cdo-78d72482bcfb1d30bb48000d57189fabc0fedc35.tar.gz
cdo-78d72482bcfb1d30bb48000d57189fabc0fedc35.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java3
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java34
2 files changed, 24 insertions, 13 deletions
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java
index 184e943..5aef758 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java
@@ -42,6 +42,9 @@ public class ClientProtocol extends SignalProtocol
case ProtocolConstants.SIGNAL_BUDDY_STATE:
return new ClientBuddyStateIndication();
+ case ProtocolConstants.SIGNAL_COLLABORATION_INITIATED:
+ return new CollaborationInitiatedIndication();
+
case ProtocolConstants.SIGNAL_MESSAGE:
return new ClientMessageIndication();
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java
index 1387a2f..8bb78b8 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java
@@ -10,13 +10,17 @@
**************************************************************************/
package org.eclipse.net4j.internal.buddies.protocol;
+import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
-import org.eclipse.net4j.internal.buddies.ClientSession;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.internal.buddies.BuddyCollaboration;
+import org.eclipse.net4j.internal.buddies.Self;
import org.eclipse.net4j.signal.Indication;
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author Eike Stepper
@@ -30,25 +34,29 @@ public class CollaborationInitiatedIndication extends Indication
@Override
protected short getSignalID()
{
- return ProtocolConstants.SIGNAL_BUDDY_REMOVED;
+ return ProtocolConstants.SIGNAL_COLLABORATION_INITIATED;
}
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
- String buddy = in.readString();
- for (int i = 0; i < 50; i++)
+ IBuddySession session = (IBuddySession)getProtocol().getInfraStructure();
+ Self self = (Self)session.getSelf();
+
+ long collaborationID = in.readLong();
+ int size = in.readInt();
+ Set<IBuddy> buddies = new HashSet<IBuddy>();
+ for (int i = 0; i < size; i++)
{
- ClientSession session = (ClientSession)getProtocol().getInfraStructure();
- if (session == null)
- {
- ConcurrencyUtil.sleep(100);
- }
- else
+ String userID = in.readString();
+ IBuddy buddy = session.getBuddies().get(userID);
+ if (buddy != null)
{
- session.buddyRemoved(buddy);
- break;
+ buddies.add(buddy);
}
}
+
+ BuddyCollaboration collaboration = new BuddyCollaboration(collaborationID, buddies);
+ self.addCollaboration(collaboration);
}
}