summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-08 05:19:27 (EDT)
committerEike Stepper2007-10-08 05:19:27 (EDT)
commit55b610b718f6840d3f78dce7c8d32b45b32a4284 (patch)
tree84aa0c82abc853feb77485cad855b98fb23b9773
parent2caffb9b531d22a32bf72be197d9616f9b8057f0 (diff)
downloadcdo-55b610b718f6840d3f78dce7c8d32b45b32a4284.zip
cdo-55b610b718f6840d3f78dce7c8d32b45b32a4284.tar.gz
cdo-55b610b718f6840d3f78dce7c8d32b45b32a4284.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/protocol/BuddiesServerProtocol.java26
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocolFactory.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java8
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java8
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java4
-rw-r--r--plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java11
8 files changed, 53 insertions, 16 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
index d5939d3..348191c 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
@@ -10,10 +10,17 @@
**************************************************************************/
package org.eclipse.net4j.buddies.internal.server.protocol;
+import org.eclipse.net4j.buddies.internal.protocol.BuddyStateIndication;
+import org.eclipse.net4j.buddies.internal.server.Buddy;
import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.IBuddy.State;
+import org.eclipse.net4j.buddies.server.IBuddyAdmin;
+import org.eclipse.net4j.buddies.server.IBuddySession;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.signal.SignalReactor;
+import java.util.Map;
+
/**
* @author Eike Stepper
*/
@@ -35,6 +42,25 @@ public class BuddiesServerProtocol extends SignalProtocol
{
case ProtocolConstants.SIGNAL_OPEN_SESSION:
return new OpenSessionIndication();
+
+ case ProtocolConstants.SIGNAL_BUDDY_STATE:
+ return new BuddyStateIndication()
+ {
+ @Override
+ protected void stateChanged(String userID, State state)
+ {
+ synchronized (IBuddyAdmin.INSTANCE)
+ {
+ Map<String, IBuddySession> sessions = IBuddyAdmin.INSTANCE.getSessions();
+ IBuddySession session = sessions.get(userID);
+ if (session != null)
+ {
+ Buddy buddy = (Buddy)session.getBuddy();
+ buddy.setState(state);
+ }
+ }
+ }
+ };
}
return null;
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocolFactory.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocolFactory.java
index d26c9a4..965f3c8 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocolFactory.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocolFactory.java
@@ -1,6 +1,6 @@
package org.eclipse.net4j.buddies.internal.server.protocol;
-import org.eclipse.net4j.buddies.protocol.BuddiesProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.internal.net4j.ServerProtocolFactory;
@@ -10,7 +10,7 @@ import org.eclipse.internal.net4j.ServerProtocolFactory;
*/
public class BuddiesServerProtocolFactory extends ServerProtocolFactory
{
- public static final String TYPE = BuddiesProtocolConstants.PROTOCOL_NAME;
+ public static final String TYPE = ProtocolConstants.PROTOCOL_NAME;
public BuddiesServerProtocolFactory()
{
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java
index 7453493..543589b 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java
@@ -11,7 +11,7 @@
package org.eclipse.net4j.buddies.internal.server.protocol;
import org.eclipse.net4j.IChannel;
-import org.eclipse.net4j.buddies.protocol.BuddiesProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -33,7 +33,7 @@ public class BuddyAddedNotification extends Request
@Override
protected short getSignalID()
{
- return BuddiesProtocolConstants.SIGNAL_BUDDY_ADDED;
+ return ProtocolConstants.SIGNAL_BUDDY_ADDED;
}
@Override
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java
index c362b9e..421d72b 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java
@@ -11,7 +11,7 @@
package org.eclipse.net4j.buddies.internal.server.protocol;
import org.eclipse.net4j.IChannel;
-import org.eclipse.net4j.buddies.protocol.BuddiesProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -33,7 +33,7 @@ public class BuddyRemovedNotification extends Request
@Override
protected short getSignalID()
{
- return BuddiesProtocolConstants.SIGNAL_BUDDY_REMOVED;
+ return ProtocolConstants.SIGNAL_BUDDY_REMOVED;
}
@Override
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
index a9f7ed3..9a1892d 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
@@ -10,8 +10,8 @@
**************************************************************************/
package org.eclipse.net4j.buddies.internal.server.protocol;
-import org.eclipse.net4j.buddies.protocol.AccountUtil;
-import org.eclipse.net4j.buddies.protocol.BuddiesProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
+import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;
import org.eclipse.net4j.signal.IndicationWithResponse;
@@ -34,7 +34,7 @@ public class LoadAccountIndication extends IndicationWithResponse
@Override
protected short getSignalID()
{
- return BuddiesProtocolConstants.SIGNAL_LOAD_ACCOUNT;
+ return ProtocolConstants.SIGNAL_LOAD_ACCOUNT;
}
@Override
@@ -47,6 +47,6 @@ public class LoadAccountIndication extends IndicationWithResponse
@Override
protected void responding(ExtendedDataOutputStream out) throws IOException
{
- AccountUtil.writeAccount(out, account);
+ ProtocolUtil.writeAccount(out, account);
}
}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
index 9b08043..c7a30f9 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
@@ -12,8 +12,8 @@ package org.eclipse.net4j.buddies.internal.server.protocol;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.buddies.internal.server.bundle.OM;
-import org.eclipse.net4j.buddies.protocol.AccountUtil;
-import org.eclipse.net4j.buddies.protocol.BuddiesProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.ProtocolUtil;
+import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
import org.eclipse.net4j.buddies.protocol.IBuddyAccount;
import org.eclipse.net4j.buddies.server.IBuddyAdmin;
import org.eclipse.net4j.buddies.server.IBuddySession;
@@ -42,7 +42,7 @@ public class OpenSessionIndication extends IndicationWithResponse
@Override
protected short getSignalID()
{
- return BuddiesProtocolConstants.SIGNAL_OPEN_SESSION;
+ return ProtocolConstants.SIGNAL_OPEN_SESSION;
}
@Override
@@ -71,7 +71,7 @@ public class OpenSessionIndication extends IndicationWithResponse
@Override
protected void responding(ExtendedDataOutputStream out) throws IOException
{
- AccountUtil.writeAccount(out, account);
+ ProtocolUtil.writeAccount(out, account);
if (account != null)
{
List<IChannel> channels = new ArrayList<IChannel>();
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java
index 9657a21..a6caec2 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java
@@ -10,12 +10,12 @@
**************************************************************************/
package org.eclipse.net4j.buddies.server;
-import org.eclipse.net4j.buddies.protocol.BuddiesProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
/**
* @author Eike Stepper
*/
public interface ServerConstants
{
- public static final String TYPE = BuddiesProtocolConstants.PROTOCOL_NAME + "server";
+ public static final String TYPE = ProtocolConstants.PROTOCOL_NAME + "server";
}
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 91296c4..2c9d8c2 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
@@ -10,7 +10,9 @@
**************************************************************************/
package org.eclipse.net4j.internal.buddies.protocol;
+import org.eclipse.net4j.buddies.internal.protocol.BuddyStateIndication;
import org.eclipse.net4j.buddies.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.protocol.IBuddy.State;
import org.eclipse.net4j.signal.SignalProtocol;
import org.eclipse.net4j.signal.SignalReactor;
@@ -39,6 +41,15 @@ public class BuddiesClientProtocol extends SignalProtocol
case ProtocolConstants.SIGNAL_BUDDY_REMOVED:
return new BuddyRemovedIndication();
+
+ case ProtocolConstants.SIGNAL_BUDDY_STATE:
+ return new BuddyStateIndication()
+ {
+ @Override
+ protected void stateChanged(String userID, State state)
+ {
+ }
+ };
}
return null;