summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-10 17:00:29 (EDT)
committerEike Stepper2007-10-10 17:00:29 (EDT)
commita04ebf6f31d67eae793b529ca63e45fd810f93ee (patch)
treea807e4a8ba26adc760cc5b953fc62528fe961a61
parentd78a684e8e3fb394b8fc3228b828f73834791a6d (diff)
downloadcdo-a04ebf6f31d67eae793b529ca63e45fd810f93ee.zip
cdo-a04ebf6f31d67eae793b529ca63e45fd810f93ee.tar.gz
cdo-a04ebf6f31d67eae793b529ca63e45fd810f93ee.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/ServerFacility.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerFacility.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerFacility.java
new file mode 100644
index 0000000..5611969
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerFacility.java
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * 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;
+
+import org.eclipse.net4j.IChannel;
+import org.eclipse.net4j.buddies.internal.protocol.Facility;
+import org.eclipse.net4j.buddies.internal.protocol.MessageNotification;
+import org.eclipse.net4j.buddies.internal.server.bundle.OM;
+import org.eclipse.net4j.buddies.protocol.IBuddy;
+import org.eclipse.net4j.buddies.protocol.ICollaboration;
+import org.eclipse.net4j.buddies.protocol.IMessage;
+import org.eclipse.net4j.util.ObjectUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class ServerFacility extends Facility
+{
+ public ServerFacility(String type)
+ {
+ super(type);
+ }
+
+ public void handleMessage(IMessage message)
+ {
+ ICollaboration collaboration = getCollaboration();
+ for (IBuddy buddy : collaboration.getElements())
+ {
+ if (!ObjectUtil.equals(buddy.getUserID(), message.getSenderID()))
+ {
+ try
+ {
+ IChannel channel = buddy.getSession().getChannel();
+ new MessageNotification(channel, message).send();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+ }
+}