summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-09 08:03:07 (EDT)
committerEike Stepper2007-10-09 08:03:07 (EDT)
commit8b072fba7146175991fde2fd69a79f0b4068111e (patch)
tree73a92953be0fc7b78789c161a78ba195ceeb6d35
parentb6877dea3ff7bf29ca40a778d7977569be52d351 (diff)
downloadcdo-8b072fba7146175991fde2fd69a79f0b4068111e.zip
cdo-8b072fba7146175991fde2fd69a79f0b4068111e.tar.gz
cdo-8b072fba7146175991fde2fd69a79f0b4068111e.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java8
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java3
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java44
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java18
7 files changed, 68 insertions, 13 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
index b0f93e9..d0fec3e 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
@@ -32,9 +32,8 @@ import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -106,7 +105,7 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
public ICollaboration initiateCollaboration(String... userIDs)
{
long id;
- List<IBuddy> buddies = new ArrayList<IBuddy>();
+ Set<IBuddy> buddies = new HashSet<IBuddy>();
synchronized (this)
{
id = ++lastCollaborationID;
@@ -116,11 +115,12 @@ public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin, I
if (session != null)
{
buddies.add(session.getSelf());
+
}
}
}
- Collaboration collaboration = new Collaboration(id, buddies.toArray(new IBuddy[buddies.size()]));
+ Collaboration collaboration = new Collaboration(id, buddies);
addCollaboration(collaboration);
return collaboration;
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
index 0084853..fd99d18 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
@@ -17,6 +17,7 @@ import org.eclipse.net4j.buddies.protocol.ICollaboration;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.Set;
/**
* @author Eike Stepper
@@ -41,7 +42,7 @@ public class ServerBuddy extends Buddy
return account;
}
- public ICollaboration initiate(IBuddy... buddies)
+ public ICollaboration initiate(Set<IBuddy> buddies)
{
// TODO Implement method ServerBuddy.initiate()
throw new UnsupportedOperationException("Not yet implemented");
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java
new file mode 100644
index 0000000..e7c52ad
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.buddies.internal.server.protocol;
+
+import org.eclipse.net4j.IChannel;
+import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class CollaborationInitiatedNotification extends Request
+{
+ private String buddy;
+
+ public CollaborationInitiatedNotification(IChannel channel, String buddy)
+ {
+ super(channel);
+ this.buddy = buddy;
+ }
+
+ @Override
+ protected short getSignalID()
+ {
+ return ProtocolConstants.SIGNAL_BUDDY_ADDED;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws IOException
+ {
+ out.writeString(buddy);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
index 904e2df..9918d31 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java
@@ -22,6 +22,8 @@ import org.eclipse.net4j.internal.buddies.protocol.InstallFacilityRequest;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.IPluginContainer;
+import java.util.Set;
+
/**
* @author Eike Stepper
*/
@@ -31,7 +33,7 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
private IBuddySession session;
- public BuddyCollaboration(long id, IBuddy[] buddies)
+ public BuddyCollaboration(long id, Set<IBuddy> buddies)
{
super(id, buddies);
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java
index 340258d..adf9fad 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java
@@ -53,7 +53,7 @@ public class ClientBuddy extends Buddy
return account;
}
- public ICollaboration initiate(IBuddy... buddies)
+ public ICollaboration initiate(Set<IBuddy> buddies)
{
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java
index 5cfb3ec..5044705 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java
@@ -48,7 +48,7 @@ public class Self extends Buddy
return account;
}
- public ICollaboration initiate(IBuddy... buddies)
+ public ICollaboration initiate(Set<IBuddy> buddies)
{
try
{
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java
index 8ae0f10..d8ff8dd 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java
@@ -18,15 +18,16 @@ import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import java.io.IOException;
+import java.util.Set;
/**
* @author Eike Stepper
*/
public class InitiateCollaborationRequest extends RequestWithConfirmation<Long>
{
- private IBuddy[] buddies;
+ private Set<IBuddy> buddies;
- public InitiateCollaborationRequest(IChannel channel, IBuddy[] buddies)
+ public InitiateCollaborationRequest(IChannel channel, Set<IBuddy> buddies)
{
super(channel);
this.buddies = buddies;
@@ -41,10 +42,17 @@ public class InitiateCollaborationRequest extends RequestWithConfirmation<Long>
@Override
protected void requesting(ExtendedDataOutputStream out) throws IOException
{
- out.writeInt(buddies.length);
- for (IBuddy buddy : buddies)
+ if (buddies == null)
{
- out.writeString(buddy.getUserID());
+ out.writeInt(0);
+ }
+ else
+ {
+ out.writeInt(buddies.size());
+ for (IBuddy buddy : buddies)
+ {
+ out.writeString(buddy.getUserID());
+ }
}
}