summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-09 07:10:17 (EDT)
committerEike Stepper2007-10-09 07:10:17 (EDT)
commite947597f34fcda5c0130e96b67ad942ed85fb5db (patch)
tree7b3be675429b2a36f7b2ca7731ad5fdf0fa9f05f
parent75dd38168e7d900b3fa2ed616cb70259d20bbfcc (diff)
downloadcdo-e947597f34fcda5c0130e96b67ad942ed85fb5db.zip
cdo-e947597f34fcda5c0130e96b67ad942ed85fb5db.tar.gz
cdo-e947597f34fcda5c0130e96b67ad942ed85fb5db.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/ServerBuddy.java14
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddyCollaboration.java6
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java18
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java12
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java24
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientMessageIndication.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java56
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java6
9 files changed, 130 insertions, 14 deletions
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 839e7a6..38dbc2d 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
@@ -12,6 +12,8 @@ package org.eclipse.net4j.buddies.internal.server;
import org.eclipse.net4j.buddies.internal.protocol.Buddy;
import org.eclipse.net4j.buddies.protocol.IAccount;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ICollaboration;
import java.util.Arrays;
import java.util.HashSet;
@@ -38,4 +40,16 @@ public class ServerBuddy extends Buddy
{
return account;
}
+
+ public ICollaboration initiate(IBuddy... buddies)
+ {
+ // TODO Implement method ServerBuddy.initiate()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public ICollaboration join(String collaborationID)
+ {
+ // TODO Implement method ServerBuddy.join()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
index 0e7a565..26df17d 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
@@ -45,13 +45,13 @@ public class InstallFacilityIndication extends IndicationWithResponse
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
- String collaborationID = in.readString();
+ long collaborationID = in.readLong();
String facilityType = in.readString();
try
{
- IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, facilityType,
- collaborationID);
+ String description = String.valueOf(collaborationID);
+ IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, facilityType, description);
Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaborations().get(collaborationID);
collaboration.addFacility(facility);
success = true;
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddyCollaboration.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddyCollaboration.java
index 0eecbf3..252e436 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddyCollaboration.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddyCollaboration.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.buddies;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
import org.eclipse.net4j.buddies.protocol.ICollaboration;
import org.eclipse.net4j.buddies.protocol.IFacility;
@@ -21,4 +22,9 @@ public interface IBuddyCollaboration extends ICollaboration
public IBuddySession getSession();
public IFacility installFacility(String type);
+
+ public IBuddy invite(String userID);
+
+ public void leave();
+
}
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 dc77e79..e65c646 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
@@ -15,14 +15,13 @@ import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.protocol.Collaboration;
import org.eclipse.net4j.buddies.internal.protocol.Message;
import org.eclipse.net4j.buddies.internal.protocol.MessageNotification;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
import org.eclipse.net4j.buddies.protocol.IFacility;
import org.eclipse.net4j.buddies.protocol.IMessage;
import org.eclipse.net4j.internal.buddies.protocol.InstallFacilityRequest;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.IPluginContainer;
-import java.util.UUID;
-
/**
* @author Eike Stepper
*/
@@ -32,9 +31,9 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
private IBuddySession session;
- public BuddyCollaboration()
+ public BuddyCollaboration(long id)
{
- super(createID());
+ super(id);
}
public IBuddySession getSession()
@@ -46,7 +45,8 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
{
try
{
- IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, type, getID());
+ String description = String.valueOf(getID());
+ IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, type, description);
boolean success = new InstallFacilityRequest(session.getChannel(), getID(), type).send(5000L);
if (success)
{
@@ -79,8 +79,12 @@ public class BuddyCollaboration extends Collaboration implements IBuddyCollabora
}
}
- private static String createID()
+ public IBuddy invite(String userID)
+ {
+ return null;
+ }
+
+ public void leave()
{
- return UUID.randomUUID().toString();
}
}
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 df5c38b..99b6187 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
@@ -12,6 +12,8 @@ package org.eclipse.net4j.internal.buddies;
import org.eclipse.net4j.buddies.internal.protocol.Buddy;
import org.eclipse.net4j.buddies.protocol.IAccount;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ICollaboration;
import java.util.Set;
@@ -51,6 +53,16 @@ public class ClientBuddy extends Buddy
return account;
}
+ public ICollaboration initiate(IBuddy... buddies)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public ICollaboration join(String collaborationID)
+ {
+ throw new UnsupportedOperationException();
+ }
+
protected IAccount loadAccount(String userID)
{
// TODO Implement method ClientBuddy.loadAccount()
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 c711e9b..a9b45ed 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
@@ -12,6 +12,10 @@ package org.eclipse.net4j.internal.buddies;
import org.eclipse.net4j.buddies.internal.protocol.Buddy;
import org.eclipse.net4j.buddies.protocol.IAccount;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ICollaboration;
+import org.eclipse.net4j.internal.buddies.protocol.InitiateCollaborationRequest;
+import org.eclipse.net4j.util.WrappedException;
import java.util.Set;
@@ -43,4 +47,24 @@ public class Self extends Buddy
{
return account;
}
+
+ public ICollaboration initiate(IBuddy... buddies)
+ {
+ try
+ {
+ long id = new InitiateCollaborationRequest(getSession().getChannel(), buddies).send(5000L);
+ BuddyCollaboration collaboration = new BuddyCollaboration(id);
+ addCollaboration(collaboration);
+ return collaboration;
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ public ICollaboration join(String collaborationID)
+ {
+ return null;
+ }
}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientMessageIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientMessageIndication.java
index 47810e6..935997e 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientMessageIndication.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientMessageIndication.java
@@ -29,7 +29,7 @@ public class ClientMessageIndication extends MessageIndication
else
{
Self self = session.getSelf();
- String collaborationID = message.getCollaborationID();
+ long collaborationID = message.getCollaborationID();
Collaboration collaboration = (Collaboration)self.getCollaborations().get(collaborationID);
collaboration.notifyMessage(message);
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
new file mode 100644
index 0000000..8ae0f10
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * 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.internal.buddies.protocol;
+
+import org.eclipse.net4j.IChannel;
+import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class InitiateCollaborationRequest extends RequestWithConfirmation<Long>
+{
+ private IBuddy[] buddies;
+
+ public InitiateCollaborationRequest(IChannel channel, IBuddy[] buddies)
+ {
+ super(channel);
+ this.buddies = buddies;
+ }
+
+ @Override
+ protected short getSignalID()
+ {
+ return ProtocolConstants.SIGNAL_INITIATE_COLLABORATION;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws IOException
+ {
+ out.writeInt(buddies.length);
+ for (IBuddy buddy : buddies)
+ {
+ out.writeString(buddy.getUserID());
+ }
+ }
+
+ @Override
+ protected Long confirming(ExtendedDataInputStream in) throws IOException
+ {
+ return in.readLong();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java
index 9238b5d..d5b53c5 100644
--- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java
+++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java
@@ -23,11 +23,11 @@ import java.io.IOException;
*/
public class InstallFacilityRequest extends RequestWithConfirmation<Boolean>
{
- private String collaborationID;
+ private long collaborationID;
private String facilityType;
- public InstallFacilityRequest(IChannel channel, String collaborationID, String facilityType)
+ public InstallFacilityRequest(IChannel channel, long collaborationID, String facilityType)
{
super(channel);
this.collaborationID = collaborationID;
@@ -43,7 +43,7 @@ public class InstallFacilityRequest extends RequestWithConfirmation<Boolean>
@Override
protected void requesting(ExtendedDataOutputStream out) throws IOException
{
- out.writeString(collaborationID);
+ out.writeLong(collaborationID);
out.writeString(facilityType);
}