p2play-commit Mailing List for P2Play (Page 2)
Status: Pre-Alpha
Brought to you by:
tisoft
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(17) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(17) |
Feb
|
Mar
(18) |
Apr
|
May
|
Jun
(1) |
Jul
(8) |
Aug
(20) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <ti...@us...> - 2007-07-02 20:17:21
|
Revision: 56
http://p2play.svn.sourceforge.net/p2play/?rev=56&view=rev
Author: tisoft
Date: 2007-07-02 13:17:13 -0700 (Mon, 02 Jul 2007)
Log Message:
-----------
improved local discovery
added locally discovered nodes to test connect dialog
Modified Paths:
--------------
P2PlayLegacy/src/de/upb/mmog/net/test/gui/logon/ConnectDialog.java
trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/LocalDiscovery.java
trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/ServiceInfo.java
trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/ServiceListener.java
trunk/P2PlayBoot/src/main/java/org/p2play/boot/pastry/Pastry.java
Modified: P2PlayLegacy/src/de/upb/mmog/net/test/gui/logon/ConnectDialog.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/test/gui/logon/ConnectDialog.java 2007-07-02 13:02:39 UTC (rev 55)
+++ P2PlayLegacy/src/de/upb/mmog/net/test/gui/logon/ConnectDialog.java 2007-07-02 20:17:13 UTC (rev 56)
@@ -7,8 +7,10 @@
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
+import java.awt.Insets;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.io.IOException;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -17,585 +19,705 @@
import java.util.Enumeration;
import javax.swing.ButtonGroup;
+import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
+import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.ListModel;
+import org.p2play.boot.discovery.LocalDiscovery;
+import org.p2play.boot.discovery.ServiceInfo;
+import org.p2play.boot.discovery.ServiceListener;
+
import de.upb.mmog.net.test.gui.util.HistoryManager;
import de.upb.mmog.net.test.gui.util.JComboBoxWithHistory;
+/**
+ * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
+ * Builder, which is free for non-commercial use. If Jigloo is being used
+ * commercially (ie, by a corporation, company or business for any purpose
+ * whatever) then you should purchase a license for each developer using Jigloo.
+ * Please visit www.cloudgarden.com for details. Use of Jigloo implies
+ * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
+ * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
+ * ANY CORPORATE OR COMMERCIAL PURPOSE.
+ */
public class ConnectDialog extends JFrame {
-
+
private JPanel jContentPane = null;
- private JLabel jLabel1 = null;
+ private JLabel jLabel1 = null;
- private JComboBoxWithHistory localPortComboBox = null;
+ private JComboBoxWithHistory localPortComboBox = null;
- private JButton connectButton = null;
+ private JButton connectButton = null;
- private JButton cancelButton = null;
+ private JButton cancelButton = null;
- private boolean canceled;
+ private boolean canceled;
- private boolean closed;
+ private boolean closed;
- private JComboBoxWithHistory userComboBox = null;
+ private JComboBoxWithHistory userComboBox = null;
- private JPasswordField passwordField = null;
+ private JPasswordField passwordField = null;
- private JLabel jLabel2 = null;
+ private JLabel jLabel2 = null;
- private JLabel jLabel3 = null;
+ private JLabel jLabel3 = null;
- private JLabel jLabel = null;
+ private JLabel jLabel = null;
- private JRadioButton httpBootRadioButton = null;
+ private JRadioButton httpBootRadioButton = null;
- private JRadioButton directBootRadioButton = null;
+ private JRadioButton directBootRadioButton = null;
- private JLabel httpBootURLLabel = null;
+ private JLabel httpBootURLLabel = null;
- private JLabel directBootHostLabel = null;
+ private JLabel directBootHostLabel = null;
- private JLabel directBootPortLabel = null;
+ private JLabel directBootPortLabel = null;
- private JComboBoxWithHistory directBootPortComboBox = null;
+ private JComboBoxWithHistory directBootPortComboBox = null;
- private JComboBoxWithHistory directBootHostComboBox = null;
+ private JComboBoxWithHistory directBootHostComboBox = null;
- private JComboBoxWithHistory httpBootURLComboBox = null;
+ private JComboBoxWithHistory httpBootURLComboBox = null;
- private JLabel jLabel4 = null;
+ private JList discoveryServiceList;
- private JComboBox localIPComboBox = null;
+ private JLabel jLabel4 = null;
+ private JScrollPane jScrollPane1;
+ private JRadioButton discoveryBootRadioButton;
- private HistoryManager historyManager;
- /**
- * This is the default constructor
- */
- private ConnectDialog() {
- super();
-
- historyManager=HistoryManager.loadHM("ConnectDialog");
-
- initialize();
- closed = false;
-
- getDirectBootRadioButton().setSelected(true);
- enableTextfields();
- }
+ private JComboBox localIPComboBox = null;
- /**
- * This method initializes this
- *
- * @return void
- */
- private void initialize() {
- this.setSize(609, 300);
- this.setTitle("Connection Dialog");
- this.setName("Connection Dialog");
- this
- .setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
- this.setContentPane(getJContentPane());
- }
+ private HistoryManager historyManager;
- /**
- * This method initializes jContentPane
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane() {
- if (jContentPane == null) {
- GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
- gridBagConstraints10.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints10.gridy = 6;
- gridBagConstraints10.weightx = 1.0;
- gridBagConstraints10.gridx = 1;
- GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
- gridBagConstraints9.gridx = 0;
- gridBagConstraints9.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints9.gridy = 6;
- jLabel4 = new JLabel();
- jLabel4.setText("Local IP:");
- GridBagConstraints gridBagConstraints81 = new GridBagConstraints();
- gridBagConstraints81.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints81.gridy = 2;
- gridBagConstraints81.weightx = 1.0;
- gridBagConstraints81.gridx = 1;
- GridBagConstraints gridBagConstraints71 = new GridBagConstraints();
- gridBagConstraints71.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints71.gridy = 4;
- gridBagConstraints71.weightx = 1.0;
- gridBagConstraints71.gridx = 1;
- GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
- gridBagConstraints6.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints6.gridy = 5;
- gridBagConstraints6.weightx = 1.0;
- gridBagConstraints6.gridx = 1;
- GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
- gridBagConstraints5.gridx = 0;
- gridBagConstraints5.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints5.gridy = 5;
- directBootPortLabel = new JLabel();
- directBootPortLabel.setText("remote port:");
- GridBagConstraints gridBagConstraints42 = new GridBagConstraints();
- gridBagConstraints42.gridx = 0;
- gridBagConstraints42.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints42.gridy = 4;
- directBootHostLabel = new JLabel();
- directBootHostLabel.setText("remote host:");
- GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
- gridBagConstraints3.gridx = 0;
- gridBagConstraints3.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints3.gridy = 2;
- httpBootURLLabel = new JLabel();
- httpBootURLLabel.setText("boot URL:");
- GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
- gridBagConstraints22.gridx = 0;
- gridBagConstraints22.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints22.gridy = 3;
- GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
- gridBagConstraints1.gridx = 0;
- gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints1.gridwidth = 2;
- gridBagConstraints1.gridy = 1;
- GridBagConstraints gridBagConstraints = new GridBagConstraints();
- gridBagConstraints.gridx = 1;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.gridy = 8;
- jLabel = new JLabel();
- jLabel
- .setText("Please open this port in your firewall for both TCP and UDP.");
- GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
- gridBagConstraints41.gridx = 0;
- gridBagConstraints41.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints41.gridy = 10;
- jLabel3 = new JLabel();
- jLabel3.setText("password:");
- GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
- gridBagConstraints31.gridx = 0;
- gridBagConstraints31.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints31.gridy = 9;
- jLabel2 = new JLabel();
- jLabel2.setText("user:");
- GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
- gridBagConstraints21.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints21.gridy = 10;
- gridBagConstraints21.weightx = 1.0;
- gridBagConstraints21.gridx = 1;
- GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
- gridBagConstraints11.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints11.gridy = 9;
- gridBagConstraints11.weightx = 1.0;
- gridBagConstraints11.gridx = 1;
- GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
- gridBagConstraints8.gridx = 0;
- gridBagConstraints8.gridy = 11;
- GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
- gridBagConstraints7.gridx = 1;
- gridBagConstraints7.gridy = 11;
- GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
- gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints4.gridy = 7;
- gridBagConstraints4.weightx = 1.0;
- gridBagConstraints4.gridx = 1;
- GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
- gridBagConstraints2.gridx = 0;
- gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints2.gridy = 7;
- jLabel1 = new JLabel();
- jLabel1.setText("local port:");
- jContentPane = new JPanel();
- jContentPane.setLayout(new GridBagLayout());
- jContentPane.add(jLabel1, gridBagConstraints2);
- jContentPane.add(getLocalPortComboBox(), gridBagConstraints4);
- jContentPane.add(getConnectButton(), gridBagConstraints7);
- jContentPane.add(getCancelButton(), gridBagConstraints8);
- jContentPane.add(getUserComboBox(), gridBagConstraints11);
- jContentPane.add(getPasswordField(), gridBagConstraints21);
- jContentPane.add(jLabel2, gridBagConstraints31);
- jContentPane.add(jLabel3, gridBagConstraints41);
- jContentPane.add(jLabel, gridBagConstraints);
- jContentPane.add(getHttpBootRadioButton(), gridBagConstraints1);
- jContentPane.add(getDirectBootRadioButton(), gridBagConstraints22);
- jContentPane.add(httpBootURLLabel, gridBagConstraints3);
- jContentPane.add(directBootHostLabel, gridBagConstraints42);
- jContentPane.add(directBootPortLabel, gridBagConstraints5);
- jContentPane.add(getDirectBootPortComboBox(), gridBagConstraints6);
- jContentPane
- .add(getDirectBootHostComboBox(), gridBagConstraints71);
- jContentPane.add(getHttpBootURLComboBox(), gridBagConstraints81);
- jContentPane.add(jLabel4, gridBagConstraints9);
- jContentPane.add(getLocalIPComboBox(), gridBagConstraints10);
+ /**
+ * This is the default constructor
+ */
+ private ConnectDialog() {
+ super();
- ButtonGroup bg = new ButtonGroup();
- bg.add(getHttpBootRadioButton());
- bg.add(getDirectBootRadioButton());
- }
- return jContentPane;
- }
+ historyManager = HistoryManager.loadHM("ConnectDialog");
- /**
- * This method initializes jTextField2
- *
- * @return javax.swing.JTextField
- */
- private JComboBoxWithHistory getLocalPortComboBox() {
- if (localPortComboBox == null) {
- localPortComboBox = new JComboBoxWithHistory(historyManager,"localPortTextField");
- //localPortTextField.setColumns(5);
- //localPortTextField.setText("10000");
- }
- return localPortComboBox;
- }
+ initialize();
+ closed = false;
- /**
- * This method initializes jButton
- *
- * @return javax.swing.JButton
- */
- private JButton getConnectButton() {
- if (connectButton == null) {
- connectButton = new JButton();
- connectButton.setText("Connect");
- connectButton
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- if (getUser() != null
- && !getUser().trim().equals("")) {
- canceled = false;
- closed = true;
- setVisible(false);
- getDirectBootHostComboBox().saveHistory();
- getHttpBootURLComboBox().saveHistory();
- getDirectBootPortComboBox().saveHistory();
- getLocalPortComboBox().saveHistory();
- getUserComboBox().saveHistory();
- }
- }
- });
- }
- return connectButton;
- }
-
- /**
- * This method initializes jButton1
- *
- * @return javax.swing.JButton
- */
- private JButton getCancelButton() {
- if (cancelButton == null) {
- cancelButton = new JButton();
- cancelButton.setText("Cancel");
- cancelButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- canceled = true;
- closed = true;
- setVisible(false);
- }
- });
- }
- return cancelButton;
- }
+ getDirectBootRadioButton().setSelected(true);
+ enableTextfields();
+ }
- public static final ConnectDialog showConnectDialog() {
- final ConnectDialog cd = new ConnectDialog();
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setSize(609, 481);
+ this.setTitle("Connection Dialog");
+ this.setName("Connection Dialog");
+ this
+ .setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
+ this.setContentPane(getJContentPane());
+ }
- new Thread() {
- @Override
+ /**
+ * This method initializes jContentPane
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
+ gridBagConstraints10.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints10.gridy = 6;
+ gridBagConstraints10.weightx = 1.0;
+ gridBagConstraints10.gridx = 1;
+ GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
+ gridBagConstraints9.gridx = 0;
+ gridBagConstraints9.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints9.gridy = 6;
+ jLabel4 = new JLabel();
+ jLabel4.setText("Local IP:");
+ GridBagConstraints gridBagConstraints81 = new GridBagConstraints();
+ gridBagConstraints81.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints81.gridy = 2;
+ gridBagConstraints81.weightx = 1.0;
+ gridBagConstraints81.gridx = 1;
+ GridBagConstraints gridBagConstraints71 = new GridBagConstraints();
+ gridBagConstraints71.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints71.gridy = 4;
+ gridBagConstraints71.weightx = 1.0;
+ gridBagConstraints71.gridx = 1;
+ GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
+ gridBagConstraints6.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints6.gridy = 5;
+ gridBagConstraints6.weightx = 1.0;
+ gridBagConstraints6.gridx = 1;
+ GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
+ gridBagConstraints5.gridx = 0;
+ gridBagConstraints5.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints5.gridy = 5;
+ directBootPortLabel = new JLabel();
+ directBootPortLabel.setText("remote port:");
+ GridBagConstraints gridBagConstraints42 = new GridBagConstraints();
+ gridBagConstraints42.gridx = 0;
+ gridBagConstraints42.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints42.gridy = 4;
+ directBootHostLabel = new JLabel();
+ directBootHostLabel.setText("remote host:");
+ GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
+ gridBagConstraints3.gridx = 0;
+ gridBagConstraints3.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints3.gridy = 2;
+ httpBootURLLabel = new JLabel();
+ httpBootURLLabel.setText("boot URL:");
+ GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
+ gridBagConstraints22.gridx = 0;
+ gridBagConstraints22.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints22.gridy = 3;
+ GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+ gridBagConstraints1.gridx = 0;
+ gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints1.gridwidth = 2;
+ gridBagConstraints1.gridy = 1;
+ GridBagConstraints gridBagConstraints = new GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.gridy = 8;
+ jLabel = new JLabel();
+ jLabel
+ .setText("Please open this port in your firewall for both TCP and UDP.");
+ GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
+ gridBagConstraints41.gridx = 0;
+ gridBagConstraints41.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints41.gridy = 10;
+ jLabel3 = new JLabel();
+ jLabel3.setText("password:");
+ GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
+ gridBagConstraints31.gridx = 0;
+ gridBagConstraints31.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints31.gridy = 9;
+ jLabel2 = new JLabel();
+ jLabel2.setText("user:");
+ GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
+ gridBagConstraints21.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints21.gridy = 10;
+ gridBagConstraints21.weightx = 1.0;
+ gridBagConstraints21.gridx = 1;
+ GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
+ gridBagConstraints11.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints11.gridy = 9;
+ gridBagConstraints11.weightx = 1.0;
+ gridBagConstraints11.gridx = 1;
+ GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
+ gridBagConstraints8.gridx = 0;
+ gridBagConstraints8.gridy = 11;
+ GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
+ gridBagConstraints7.gridx = 1;
+ gridBagConstraints7.gridy = 11;
+ GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
+ gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints4.gridy = 7;
+ gridBagConstraints4.weightx = 1.0;
+ gridBagConstraints4.gridx = 1;
+ GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
+ gridBagConstraints2.gridx = 0;
+ gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints2.gridy = 7;
+ jLabel1 = new JLabel();
+ jLabel1.setText("local port:");
+ jContentPane = new JPanel();
+ GridBagLayout jContentPaneLayout = new GridBagLayout();
+ jContentPane.setLayout(jContentPaneLayout);
+ jContentPaneLayout.columnWeights = new double[] { 0.1, 0.1 };
+ jContentPaneLayout.columnWidths = new int[] { 7, 7 };
+ jContentPaneLayout.rowWeights = new double[] { 0.1, 0.1, 0.1, 0.1,
+ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 };
+ jContentPaneLayout.rowHeights = new int[] { 7, 7, 7, 7, 7, 7, 20,
+ 7, 7, 7, 20, 7, 7, 7 };
+ jContentPane.add(jLabel1, new GridBagConstraints(0, 9, 1, 1, 0.0,
+ 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
+ new Insets(0, 0, 0, 0), 0, 0));
+ jContentPane.add(getLocalPortComboBox(),
+ new GridBagConstraints(1, 9, 1, 1, 1.0, 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0,
+ 0), 0, 0));
+ jContentPane.add(getConnectButton(), new GridBagConstraints(1, 13,
+ 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
+ jContentPane.add(getCancelButton(), new GridBagConstraints(0, 13,
+ 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
+ jContentPane.add(getUserComboBox(),
+ new GridBagConstraints(1, 11, 1, 1, 1.0, 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0,
+ 0), 0, 0));
+ jContentPane.add(getPasswordField(),
+ new GridBagConstraints(1, 12, 1, 1, 1.0, 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0,
+ 0), 0, 0));
+ jContentPane.add(jLabel2, new GridBagConstraints(0, 11, 1, 1, 0.0,
+ 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
+ new Insets(0, 0, 0, 0), 0, 0));
+ jContentPane.add(jLabel3, new GridBagConstraints(0, 12, 1, 1, 0.0,
+ 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
+ new Insets(0, 0, 0, 0), 0, 0));
+ jContentPane.add(jLabel,
+ new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0,
+ 0), 0, 0));
+ jContentPane.add(getHttpBootRadioButton(), gridBagConstraints1);
+ jContentPane.add(getDirectBootRadioButton(), gridBagConstraints22);
+ jContentPane.add(httpBootURLLabel, gridBagConstraints3);
+ jContentPane.add(directBootHostLabel, gridBagConstraints42);
+ jContentPane.add(directBootPortLabel, gridBagConstraints5);
+ jContentPane.add(getDirectBootPortComboBox(), gridBagConstraints6);
+ jContentPane.add(getDirectBootHostComboBox(), gridBagConstraints71);
+ jContentPane.add(getHttpBootURLComboBox(), gridBagConstraints81);
+ jContentPane.add(jLabel4, new GridBagConstraints(0, 8, 1, 1, 0.0,
+ 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
+ new Insets(0, 0, 0, 0), 0, 0));
+ jContentPane.add(getLocalIPComboBox(),
+ new GridBagConstraints(1, 8, 1, 1, 1.0, 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0,
+ 0), 0, 0));
+ jContentPane.add(getDiscoveryBootRadioButton(),
+ new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0,
+ GridBagConstraints.CENTER, GridBagConstraints.NONE,
+ new Insets(0, 0, 0, 0), 0, 0));
+ jContentPane.add(getJScrollPane1(), new GridBagConstraints(1, 7, 1,
+ 1, 0.0, 0.0, GridBagConstraints.EAST,
+ GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
+
+ ButtonGroup bg = new ButtonGroup();
+ bg.add(getHttpBootRadioButton());
+ bg.add(getDirectBootRadioButton());
+ bg.add(getDiscoveryBootRadioButton());
+ }
+ return jContentPane;
+ }
+
+ /**
+ * This method initializes jTextField2
+ *
+ * @return javax.swing.JTextField
+ */
+ private JComboBoxWithHistory getLocalPortComboBox() {
+ if (localPortComboBox == null) {
+ localPortComboBox = new JComboBoxWithHistory(historyManager,
+ "localPortTextField");
+ // localPortTextField.setColumns(5);
+ // localPortTextField.setText("10000");
+ }
+ return localPortComboBox;
+ }
+
+ /**
+ * This method initializes jButton
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getConnectButton() {
+ if (connectButton == null) {
+ connectButton = new JButton();
+ connectButton.setText("Connect");
+ connectButton
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ if (getUser() != null
+ && !getUser().trim().equals("")) {
+ canceled = false;
+ closed = true;
+ setVisible(false);
+ getDirectBootHostComboBox().saveHistory();
+ getHttpBootURLComboBox().saveHistory();
+ getDirectBootPortComboBox().saveHistory();
+ getLocalPortComboBox().saveHistory();
+ getUserComboBox().saveHistory();
+ }
+ }
+ });
+ }
+ return connectButton;
+ }
+
+ /**
+ * This method initializes jButton1
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getCancelButton() {
+ if (cancelButton == null) {
+ cancelButton = new JButton();
+ cancelButton.setText("Cancel");
+ cancelButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ canceled = true;
+ closed = true;
+ setVisible(false);
+ }
+ });
+ }
+ return cancelButton;
+ }
+
+ public static final ConnectDialog showConnectDialog() {
+ final ConnectDialog cd = new ConnectDialog();
+
+ new Thread() {
+ @Override
public void run() {
- cd.setVisible(true);
- };
- }.start();
+ cd.setVisible(true);
+ };
+ }.start();
- while (!cd.closed) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
+ while (!cd.closed) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
- return cd;
- }
+ return cd;
+ }
- private void fillLocalIPComboBox() {
- try {
- NetworkInterface iface = null;
+ private void fillLocalIPComboBox() {
+ try {
+ NetworkInterface iface = null;
- for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces
- .hasMoreElements();) {
- iface = (NetworkInterface) ifaces.nextElement();
- InetAddress ia = null;
- for (Enumeration ips = iface.getInetAddresses(); ips
- .hasMoreElements();) {
- ia = (InetAddress) ips.nextElement();
- //only add Inetv4 addresses for now
- if(ia instanceof Inet4Address) {
+ for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces
+ .hasMoreElements();) {
+ iface = (NetworkInterface) ifaces.nextElement();
+ InetAddress ia = null;
+ for (Enumeration ips = iface.getInetAddresses(); ips
+ .hasMoreElements();) {
+ ia = (InetAddress) ips.nextElement();
+ // only add Inetv4 addresses for now
+ if (ia instanceof Inet4Address) {
getLocalIPComboBox().addItem(ia.getHostAddress());
}
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
- }
+ }
- public boolean isCanceled() {
- return canceled;
- }
+ public boolean isCanceled() {
+ return canceled;
+ }
- public boolean isBootHttp() {
- return getHttpBootRadioButton().isSelected();
- }
+ public boolean isBootHttp() {
+ return getHttpBootRadioButton().isSelected();
+ }
- public boolean isBootDirect() {
- return !isBootHttp();
- }
+ public boolean isBootDirect() {
+ return getDirectBootRadioButton().isSelected();
+ }
- public String getHttpURL() {
- return getHttpBootURLComboBox().getSelectedItem().toString();
- }
+ public String getHttpURL() {
+ return getHttpBootURLComboBox().getSelectedItem().toString();
+ }
- public InetSocketAddress getDirectAddress() {
- return new InetSocketAddress(getDirectBootHostComboBox().getSelectedItem().toString(),
- Integer.parseInt(getDirectBootPortComboBox().getSelectedItem().toString()));
- }
+ public InetSocketAddress getDirectAddress() {
+ if(getDiscoveryBootRadioButton().isSelected()){
+ return ((ServiceInfo)discoveryServiceList.getSelectedValue()).getAddress();
+ }else
+ return new InetSocketAddress(getDirectBootHostComboBox()
+ .getSelectedItem().toString(), Integer
+ .parseInt(getDirectBootPortComboBox().getSelectedItem()
+ .toString()));
+ }
- public String getlocalAddress() {
- return getLocalIPComboBox().getSelectedItem().toString();
- }
+ public String getlocalAddress() {
+ return getLocalIPComboBox().getSelectedItem().toString();
+ }
- public int getLocalPort() {
- return Integer.parseInt(getLocalPortComboBox().getSelectedItem().toString());
+ public int getLocalPort() {
+ return Integer.parseInt(getLocalPortComboBox().getSelectedItem()
+ .toString());
- }
+ }
- public String getUser() {
- return getUserComboBox().getSelectedItem().toString();
- }
+ public String getUser() {
+ return getUserComboBox().getSelectedItem().toString();
+ }
- public char[] getPassword() {
- return getPasswordField().getPassword();
- }
+ public char[] getPassword() {
+ return getPasswordField().getPassword();
+ }
- /**
- * This method initializes jTextField
- *
- * @return javax.swing.JTextField
- */
- private JComboBoxWithHistory getUserComboBox() {
- if (userComboBox == null) {
- userComboBox = new JComboBoxWithHistory(historyManager,"userTextField");
- }
- return userComboBox;
- }
+ /**
+ * This method initializes jTextField
+ *
+ * @return javax.swing.JTextField
+ */
+ private JComboBoxWithHistory getUserComboBox() {
+ if (userComboBox == null) {
+ userComboBox = new JComboBoxWithHistory(historyManager,
+ "userTextField");
+ }
+ return userComboBox;
+ }
- /**
- * This method initializes jPasswordField
- *
- * @return javax.swing.JPasswordField
- */
- private JPasswordField getPasswordField() {
- if (passwordField == null) {
- passwordField = new JPasswordField();
- }
- return passwordField;
- }
+ /**
+ * This method initializes jPasswordField
+ *
+ * @return javax.swing.JPasswordField
+ */
+ private JPasswordField getPasswordField() {
+ if (passwordField == null) {
+ passwordField = new JPasswordField();
+ }
+ return passwordField;
+ }
- /**
- * This method initializes jRadioButton
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getHttpBootRadioButton() {
- if (httpBootRadioButton == null) {
- httpBootRadioButton = new JRadioButton();
- httpBootRadioButton.setText("Boot from HTTP");
- httpBootRadioButton.setSelected(true);
- httpBootRadioButton
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- enableTextfields();
- }
- });
- }
- return httpBootRadioButton;
- }
+ /**
+ * This method initializes jRadioButton
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getHttpBootRadioButton() {
+ if (httpBootRadioButton == null) {
+ httpBootRadioButton = new JRadioButton();
+ httpBootRadioButton.setText("Boot from HTTP");
+ httpBootRadioButton.setSelected(true);
+ httpBootRadioButton
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ enableTextfields();
+ }
+ });
+ }
+ return httpBootRadioButton;
+ }
- /**
- * This method initializes jRadioButton
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getDirectBootRadioButton() {
- if (directBootRadioButton == null) {
- directBootRadioButton = new JRadioButton();
- directBootRadioButton.setText("Boot directly from PastryNode");
- directBootRadioButton
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- enableTextfields();
- }
- });
- }
- return directBootRadioButton;
- }
+ /**
+ * This method initializes jRadioButton
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getDirectBootRadioButton() {
+ if (directBootRadioButton == null) {
+ directBootRadioButton = new JRadioButton();
+ directBootRadioButton.setText("Boot directly from PastryNode");
+ directBootRadioButton
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ enableTextfields();
+ }
+ });
+ }
+ return directBootRadioButton;
+ }
- /**
- * This method initializes jTextField
- *
- * @return javax.swing.JTextField
- */
- private JComboBoxWithHistory getDirectBootPortComboBox() {
- if (directBootPortComboBox == null) {
- directBootPortComboBox = new JComboBoxWithHistory(historyManager,"directBootPortTextField");
- directBootPortComboBox.setEnabled(false);
- }
- return directBootPortComboBox;
- }
+ /**
+ * This method initializes jTextField
+ *
+ * @return javax.swing.JTextField
+ */
+ private JComboBoxWithHistory getDirectBootPortComboBox() {
+ if (directBootPortComboBox == null) {
+ directBootPortComboBox = new JComboBoxWithHistory(historyManager,
+ "directBootPortTextField");
+ directBootPortComboBox.setEnabled(false);
+ }
+ return directBootPortComboBox;
+ }
- /**
- * This method initializes jTextField1
- *
- * @return javax.swing.JTextField
- */
- private JComboBoxWithHistory getDirectBootHostComboBox() {
- if (directBootHostComboBox == null) {
- directBootHostComboBox = new JComboBoxWithHistory(historyManager,"BootHostTextField");
- directBootHostComboBox.setEnabled(false);
- }
- return directBootHostComboBox;
- }
+ /**
+ * This method initializes jTextField1
+ *
+ * @return javax.swing.JTextField
+ */
+ private JComboBoxWithHistory getDirectBootHostComboBox() {
+ if (directBootHostComboBox == null) {
+ directBootHostComboBox = new JComboBoxWithHistory(historyManager,
+ "BootHostTextField");
+ directBootHostComboBox.setEnabled(false);
+ }
+ return directBootHostComboBox;
+ }
- /**
- * This method initializes jTextField2
- *
- * @return javax.swing.JTextField
- */
- private JComboBoxWithHistory getHttpBootURLComboBox() {
- if (httpBootURLComboBox == null) {
- httpBootURLComboBox = new JComboBoxWithHistory(historyManager,"httpBootURLTextField");
- //httpBootURLTextField.setText("http://tisoft.de/projects/pastry/boot.php");
- }
- return httpBootURLComboBox;
- }
+ /**
+ * This method initializes jTextField2
+ *
+ * @return javax.swing.JTextField
+ */
+ private JComboBoxWithHistory getHttpBootURLComboBox() {
+ if (httpBootURLComboBox == null) {
+ httpBootURLComboBox = new JComboBoxWithHistory(historyManager,
+ "httpBootURLTextField");
+ // httpBootURLTextField.setText("http://tisoft.de/projects/pastry/boot.php");
+ }
+ return httpBootURLComboBox;
+ }
- /**
- *
- */
- private void enableTextfields() {
- if (getHttpBootRadioButton().isSelected()) {
- getHttpBootURLComboBox().setEnabled(true);
- getDirectBootHostComboBox().setEnabled(false);
- getDirectBootPortComboBox().setEnabled(false);
- } else {
- getHttpBootURLComboBox().setEnabled(false);
- getDirectBootHostComboBox().setEnabled(true);
- getDirectBootPortComboBox().setEnabled(true);
- }
- }
+ /**
+ *
+ */
+ private void enableTextfields() {
+ if (getHttpBootRadioButton().isSelected()) {
+ getHttpBootURLComboBox().setEnabled(true);
+ getDirectBootHostComboBox().setEnabled(false);
+ getDirectBootPortComboBox().setEnabled(false);
+ getDiscoveryServiceList().setEnabled(false);
+ } else if (getDirectBootRadioButton().isSelected()) {
+ getHttpBootURLComboBox().setEnabled(false);
+ getDirectBootHostComboBox().setEnabled(true);
+ getDirectBootPortComboBox().setEnabled(true);
+ getDiscoveryServiceList().setEnabled(false);
+ } else {
+ getHttpBootURLComboBox().setEnabled(false);
+ getDirectBootHostComboBox().setEnabled(false);
+ getDirectBootPortComboBox().setEnabled(false);
+ getDiscoveryServiceList().setEnabled(true);
+ }
+ }
- /**
- * This method initializes jComboBox
- *
- * @return javax.swing.JComboBox
- */
- private JComboBox getLocalIPComboBox() {
- if (localIPComboBox == null) {
- localIPComboBox = new JComboBox();
- fillLocalIPComboBox();
-
- localIPComboBox.addItemListener(new ItemListener(){public void itemStateChanged(ItemEvent e) {
-
- String user=getlocalAddress();
- try {
- String hostName = InetAddress.getByName(getlocalAddress()).getHostName();
-
- if(!hostName.equals(user)&&hostName.contains(".")){
- hostName=hostName.substring(0,hostName.indexOf("."));
+ /**
+ * This method initializes jComboBox
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getLocalIPComboBox() {
+ if (localIPComboBox == null) {
+ localIPComboBox = new JComboBox();
+ fillLocalIPComboBox();
+
+ localIPComboBox.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent e) {
+
+ String user = getlocalAddress();
+ try {
+ String hostName = InetAddress.getByName(
+ getlocalAddress()).getHostName();
+
+ if (!hostName.equals(user) && hostName.contains(".")) {
+ hostName = hostName.substring(0, hostName
+ .indexOf("."));
+ }
+
+ user = hostName;
+ } catch (UnknownHostException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
}
-
- user = hostName;
- } catch (UnknownHostException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
+
+ getUserComboBox().addItem(user);
+ getUserComboBox().setSelectedItem(user);
}
-
- getUserComboBox().addItem(user);
- getUserComboBox().setSelectedItem(user);
- }});
- }
- return localIPComboBox;
- }
-} // @jve:decl-index=0:visual-constraint="10,10"
+ });
+ }
+ return localIPComboBox;
+ }
+ private JRadioButton getDiscoveryBootRadioButton() {
+ if (discoveryBootRadioButton == null) {
+ discoveryBootRadioButton = new JRadioButton();
+ discoveryBootRadioButton.setText("Boot from discovered service");
+ discoveryBootRadioButton
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ enableTextfields();
+ }
+ });
+ }
+ return discoveryBootRadioButton;
+ }
+
+ private JList getDiscoveryServiceList() {
+ if (discoveryServiceList == null) {
+ final DefaultComboBoxModel discoveryServiceListModel = new DefaultComboBoxModel();
+ try {
+ new LocalDiscovery().discoverService(new ServiceListener() {
+ public void addServiceInfo(ServiceInfo info) {
+ System.out.println("Adding: " + info);
+ discoveryServiceListModel.addElement(info);
+ }
+
+ public void removeServiceInfo(ServiceInfo info) {
+ System.out.println("Removing: " + info);
+ discoveryServiceListModel.removeElement(info);
+ }
+ });
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ discoveryServiceList = new JList();
+ discoveryServiceList.setModel(discoveryServiceListModel);
+ }
+ return discoveryServiceList;
+ }
+
+ private JScrollPane getJScrollPane1() {
+ if (jScrollPane1 == null) {
+ jScrollPane1 = new JScrollPane();
+ jScrollPane1.setViewportView(getDiscoveryServiceList());
+ }
+ return jScrollPane1;
+ }
+
+} // @jve:decl-index=0:visual-constraint="10,10"
+
/*
- * $Log: ConnectDialog.java,v $
- * Revision 1.11 2006/10/25 11:56:12 tisoft_media
+ * $Log: ConnectDialog.java,v $ Revision 1.11 2006/10/25 11:56:12 tisoft_media
* use hostname as default username
- *
- * Revision 1.10 2006/10/09 09:59:49 tisoft_media
- * some code cleanup
- *
- * Revision 1.9 2006/09/21 13:43:35 tisoft_media
- * remmeved password checking
- *
- * Revision 1.7 2006/09/21 13:18:37 giessman
- * Some changes
- *
- * Revision 1.6 2006/09/21 10:49:27 obi
- * OiOi
- *
- * Revision 1.5 2006/07/03 19:03:25 tisoft_media
- * code cleanup
- *
- * Revision 1.4 2006/04/10 17:22:36 tisoft_media
- * changed HistoryManager a bit
- * Moved some Past stuff to BlockingPast
- * Added first implementation of PastKeyManager
- *
- * Revision 1.3 2006/03/29 10:22:04 brinksmeier
- * refactoring
- *
- * Revision 1.2 2006/03/28 14:23:49 brinksmeier
- * alles mit toller history
- *
- * Revision 1.1 2006/03/28 07:55:30 tisoft_media
- * initial commit
- * can boot into the Pastry Network
- *
- * Revision 1.1 2006/02/14 15:36:57 tisoft_media
- * partly working
- * dots can move and change region controlers
- * region controllers are started dynamically
- * no interaction between region controllers yet
- *
- * Revision 1.1 2006/01/31 16:05:44 tisoft_media
- * initial commit
- *
- * Revision 1.5 2005/12/08 18:45:24 markus
- * organized imports
- *
- * Revision 1.4 2005/12/08 12:21:08 markus
- * added default http boot url
- *
- * Revision 1.3 2005/12/06 21:43:45 markus
- * show only ipv4 addresses
- *
- * Revision 1.2 2005/12/06 21:33:15 markus
- * added combo box for local address
- *
- * Revision 1.1 2005/11/10 23:05:36 markus
- * initial commit
- *
- * Revision 1.1 2005/10/11 13:19:56 markus
- * initial working chat client
- *
+ *
+ * Revision 1.10 2006/10/09 09:59:49 tisoft_media some code cleanup
+ *
+ * Revision 1.9 2006/09/21 13:43:35 tisoft_media remmeved password checking
+ *
+ * Revision 1.7 2006/09/21 13:18:37 giessman Some changes
+ *
+ * Revision 1.6 2006/09/21 10:49:27 obi OiOi
+ *
+ * Revision 1.5 2006/07/03 19:03:25 tisoft_media code cleanup
+ *
+ * Revision 1.4 2006/04/10 17:22:36 tisoft_media changed HistoryManager a bit
+ * Moved some Past stuff to BlockingPast Added first implementation of
+ * PastKeyManager
+ *
+ * Revision 1.3 2006/03/29 10:22:04 brinksmeier refactoring
+ *
+ * Revision 1.2 2006/03/28 14:23:49 brinksmeier alles mit toller history
+ *
+ * Revision 1.1 2006/03/28 07:55:30 tisoft_media initial commit can boot into
+ * the Pastry Network
+ *
+ * Revision 1.1 2006/02/14 15:36:57 tisoft_media partly working dots can move
+ * and change region controlers region controllers are started dynamically no
+ * interaction between region controllers yet
+ *
+ * Revision 1.1 2006/01/31 16:05:44 tisoft_media initial commit
+ *
+ * Revision 1.5 2005/12/08 18:45:24 markus organized imports
+ *
+ * Revision 1.4 2005/12/08 12:21:08 markus added default http boot url
+ *
+ * Revision 1.3 2005/12/06 21:43:45 markus show only ipv4 addresses
+ *
+ * Revision 1.2 2005/12/06 21:33:15 markus added combo box for local address
+ *
+ * Revision 1.1 2005/11/10 23:05:36 markus initial commit
+ *
+ * Revision 1.1 2005/10/11 13:19:56 markus initial working chat client
+ *
*/
\ No newline at end of file
Modified: trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/LocalDiscovery.java
===================================================================
--- trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/LocalDiscovery.java 2007-07-02 13:02:39 UTC (rev 55)
+++ trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/LocalDiscovery.java 2007-07-02 20:17:13 UTC (rev 56)
@@ -1,38 +1 @@
-package org.p2play.boot.discovery;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-
-import javax.jmdns.JmDNS;
-import javax.jmdns.ServiceEvent;
-
-public class LocalDiscovery {
- private JmDNS jmdns;
-
- public LocalDiscovery() throws IOException {
- jmdns = new JmDNS();
- }
-
- public void addService(String name, int port) throws IOException {
- jmdns.registerService(new javax.jmdns.ServiceInfo("_p2play._tcp.local.", name
- + "._p2play._tcp.local.", port, "P2Play - Service"));
-
- }
-
- public void discoverService(final ServiceListener listener) {
- jmdns.addServiceListener("_p2play._tcp.local.", new javax.jmdns.ServiceListener(){
- public void serviceAdded(ServiceEvent arg0) {
- jmdns.requestServiceInfo(arg0.getType(), arg0.getName());
- }
-
- public void serviceRemoved(ServiceEvent arg0) {
-
- }
-
- public void serviceResolved(ServiceEvent arg0) {
- listener.addServiceInfo(new ServiceInfo(arg0.getName(), new InetSocketAddress(arg0.getInfo().getInetAddress(),arg0.getInfo().getPort())));
-
- }
- });
- }
-}
+nking.gad.de/banking/banking;jsessionid=4447ED60BA4FB2B170C60AA08D6547A6.node4?bankidTimeout=4453&viewName=HoleUmsatzDetails&action=HoleAlleUmsaetze&applId=ib_banking&frame=content&timeout=4453[203602139.1\xD4 |
|
From: <ti...@us...> - 2007-07-02 13:02:39
|
Revision: 55
http://p2play.svn.sourceforge.net/p2play/?rev=55&view=rev
Author: tisoft
Date: 2007-07-02 06:02:39 -0700 (Mon, 02 Jul 2007)
Log Message:
-----------
added jmdns for local discovery of p2play nodes
Modified Paths:
--------------
trunk/P2PlayBoot/pom.xml
trunk/P2PlayBoot/src/main/java/org/p2play/boot/pastry/Pastry.java
Added Paths:
-----------
trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/
trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/LocalDiscovery.java
trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/ServiceInfo.java
trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/ServiceListener.java
Modified: trunk/P2PlayBoot/pom.xml
===================================================================
--- trunk/P2PlayBoot/pom.xml 2007-07-02 09:53:43 UTC (rev 54)
+++ trunk/P2PlayBoot/pom.xml 2007-07-02 13:02:39 UTC (rev 55)
@@ -28,14 +28,19 @@
</plugin>
</plugins>
</build>
-
- <dependencies>
- <dependency>
- <groupId>commons-vfs</groupId>
- <artifactId>commons-vfs</artifactId>
- <version>1.0</version>
- </dependency>
+
+ <dependencies>
<dependency>
+ <groupId>jmdns</groupId>
+ <artifactId>jmdns</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-vfs</groupId>
+ <artifactId>commons-vfs</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
<groupId>de.tisoft.maven.freepastry</groupId>
<artifactId>FreePastry</artifactId>
<version>2.1-SNAPSHOT</version>
Added: trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/LocalDiscovery.java
===================================================================
--- trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/LocalDiscovery.java (rev 0)
+++ trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/LocalDiscovery.java 2007-07-02 13:02:39 UTC (rev 55)
@@ -0,0 +1,38 @@
+package org.p2play.boot.discovery;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
+import javax.jmdns.JmDNS;
+import javax.jmdns.ServiceEvent;
+
+public class LocalDiscovery {
+ private JmDNS jmdns;
+
+ public LocalDiscovery() throws IOException {
+ jmdns = new JmDNS();
+ }
+
+ public void addService(String name, int port) throws IOException {
+ jmdns.registerService(new javax.jmdns.ServiceInfo("_p2play._tcp.local.", name
+ + "._p2play._tcp.local.", port, "P2Play - Service"));
+
+ }
+
+ public void discoverService(final ServiceListener listener) {
+ jmdns.addServiceListener("_p2play._tcp.local.", new javax.jmdns.ServiceListener(){
+ public void serviceAdded(ServiceEvent arg0) {
+ jmdns.requestServiceInfo(arg0.getType(), arg0.getName());
+ }
+
+ public void serviceRemoved(ServiceEvent arg0) {
+
+ }
+
+ public void serviceResolved(ServiceEvent arg0) {
+ listener.addServiceInfo(new ServiceInfo(arg0.getName(), new InetSocketAddress(arg0.getInfo().getInetAddress(),arg0.getInfo().getPort())));
+
+ }
+ });
+ }
+}
Added: trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/ServiceInfo.java
===================================================================
--- trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/ServiceInfo.java (rev 0)
+++ trunk/P2PlayBoot/src/main/java/org/p2play/boot/discovery/ServiceInfo.java 2007-07-02 13:02:39 UTC (rev 55)
@@ -0,0 +1 @@
+.http://www.otrforum.com/showthread.php?t=35150[203155796.4oE |
|
From: <ti...@us...> - 2007-07-02 09:53:44
|
Revision: 54
http://p2play.svn.sourceforge.net/p2play/?rev=54&view=rev
Author: tisoft
Date: 2007-07-02 02:53:43 -0700 (Mon, 02 Jul 2007)
Log Message:
-----------
added maven2 support
Modified Paths:
--------------
P2PlayLegacy/.classpath
P2PlayLegacy/.project
Added Paths:
-----------
P2PlayLegacy/pom.xml
Modified: P2PlayLegacy/.classpath
===================================================================
--- P2PlayLegacy/.classpath 2007-06-05 18:48:57 UTC (rev 53)
+++ P2PlayLegacy/.classpath 2007-07-02 09:53:43 UTC (rev 54)
@@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/P2Play"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: P2PlayLegacy/.project
===================================================================
--- P2PlayLegacy/.project 2007-06-05 18:48:57 UTC (rev 53)
+++ P2PlayLegacy/.project 2007-07-02 09:53:43 UTC (rev 54)
@@ -10,8 +10,14 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>
Added: P2PlayLegacy/pom.xml
===================================================================
--- P2PlayLegacy/pom.xml (rev 0)
+++ P2PlayLegacy/pom.xml 2007-07-02 09:53:43 UTC (rev 54)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.p2play</groupId>
+ <artifactId>P2PlayLegacy</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <distributionManagement>
+ <repository>
+ <id>maven.tisoft.de</id>
+ <url>ftp://maven.tisoft.de/repository</url>
+ </repository>
+ </distributionManagement>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ftp</artifactId>
+ </extension>
+ </extensions>
+ <sourceDirectory>${basedir}/src</sourceDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/jars/freepastry</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.p2play</groupId>
+ <artifactId>P2Play</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-06-05 19:45:11
|
Revision: 53
http://p2play.svn.sourceforge.net/p2play/?rev=53&view=rev
Author: tisoft
Date: 2007-06-05 11:48:57 -0700 (Tue, 05 Jun 2007)
Log Message:
-----------
added distributionManagment
Modified Paths:
--------------
trunk/P2Play/pom.xml
trunk/P2PlayBoot/pom.xml
Modified: trunk/P2Play/pom.xml
===================================================================
--- trunk/P2Play/pom.xml 2007-03-23 20:23:47 UTC (rev 52)
+++ trunk/P2Play/pom.xml 2007-06-05 18:48:57 UTC (rev 53)
@@ -1,46 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>P2Play</groupId>
- <artifactId>P2Play</artifactId>
- <version>0.0.1</version>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>javolution</groupId>
- <artifactId>javolution</artifactId>
- <version>4.2.6</version>
- </dependency>
- <dependency>
- <groupId>pnuts</groupId>
- <artifactId>pnuts</artifactId>
- <version>1.2-BETA</version>
- </dependency>
- <dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>P2Play</groupId>
- <artifactId>P2PlayBoot</artifactId>
- <version>0.0.1</version>
- </dependency>
- <dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- <version>1.2.1</version>
- </dependency>
- </dependencies>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.p2play</groupId>
+ <artifactId>P2Play</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <distributionManagement>
+ <repository>
+ <id>maven.tisoft.de</id>
+ <url>ftp://maven.tisoft.de/repository</url>
+ </repository>
+ </distributionManagement>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ftp</artifactId>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>javolution</groupId>
+ <artifactId>javolution</artifactId>
+ <version>4.2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>pnuts</groupId>
+ <artifactId>pnuts</artifactId>
+ <version>1.2-BETA</version>
+ </dependency>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.p2play</groupId>
+ <artifactId>P2PlayBoot</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
Modified: trunk/P2PlayBoot/pom.xml
===================================================================
--- trunk/P2PlayBoot/pom.xml 2007-03-23 20:23:47 UTC (rev 52)
+++ trunk/P2PlayBoot/pom.xml 2007-06-05 18:48:57 UTC (rev 53)
@@ -1,32 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
- <modelVersion>4.0.0</modelVersion>
- <groupId>P2Play</groupId>
- <artifactId>P2PlayBoot</artifactId>
- <version>0.0.1</version>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>commons-vfs</groupId>
- <artifactId>commons-vfs</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>FreePastry</groupId>
- <artifactId>FreePastry</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.p2play</groupId>
+ <artifactId>P2PlayBoot</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <distributionManagement>
+ <repository>
+ <id>maven.tisoft.de</id>
+ <url>ftp://maven.tisoft.de/repository</url>
+ </repository>
+ </distributionManagement>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ftp</artifactId>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-vfs</groupId>
+ <artifactId>commons-vfs</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>de.tisoft.maven.freepastry</groupId>
+ <artifactId>FreePastry</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-23 20:23:48
|
Revision: 52
http://p2play.svn.sourceforge.net/p2play/?rev=52&view=rev
Author: tisoft
Date: 2007-03-23 13:23:47 -0700 (Fri, 23 Mar 2007)
Log Message:
-----------
LobbySockets work now
Modified Paths:
--------------
trunk/P2Play/src/main/java/org/p2play/lobby/ClientServerGameInfo.java
trunk/P2Play/src/main/java/org/p2play/lobby/GameInfo.java
trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java
trunk/P2Play/src/main/java/org/p2play/lobby/LobbyListener.java
trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java
trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyMessage.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/ScribeLobby.java
Added Paths:
-----------
trunk/P2Play/src/main/java/org/p2play/lobby/LobbyFactory.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyApplication.java
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/ClientServerGameInfo.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/ClientServerGameInfo.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/ClientServerGameInfo.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby;
import java.io.IOException;
@@ -4,24 +22,20 @@
import rice.p2p.commonapi.Endpoint;
import rice.p2p.commonapi.NodeHandle;
-import rice.p2p.commonapi.appsocket.AppSocketReceiver;
import rice.p2p.commonapi.rawserialization.InputBuffer;
import rice.p2p.commonapi.rawserialization.OutputBuffer;
public class ClientServerGameInfo implements GameInfo{
private String name;
private NodeHandle handle;
-
- private Endpoint endpoint;
public ClientServerGameInfo(Endpoint endpoint, InputBuffer buffer) throws IOException{
this.name=buffer.readUTF();
this.handle=endpoint.readNodeHandle(buffer);
}
- public ClientServerGameInfo(Endpoint endpoint, String name, AppSocketReceiver receiver){
+ public ClientServerGameInfo(Endpoint endpoint, String name){
this(endpoint,name,endpoint.getLocalNodeHandle());
- endpoint.accept(receiver);
}
protected ClientServerGameInfo(Endpoint endpoint, String name, NodeHandle handle) {
@@ -38,10 +52,6 @@
return handle;
}
- public void connect(AppSocketReceiver receiver){
- endpoint.connect(handle, receiver, 60);
- }
-
public void serialize(OutputBuffer buf) throws IOException {
buf.writeUTF(name);
handle.serialize(buf);
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/GameInfo.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/GameInfo.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/GameInfo.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,11 +1,30 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby;
import java.io.IOException;
+import java.io.Serializable;
import rice.p2p.commonapi.NodeHandle;
import rice.p2p.commonapi.rawserialization.OutputBuffer;
-public interface GameInfo {
+public interface GameInfo extends Serializable{
public String getName();
public NodeHandle getHandle();
public void serialize(OutputBuffer buf) throws IOException;
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby;
@@ -9,4 +27,6 @@
public void addLobbyListener(LobbyListener listener);
public void removeLobbyListener(LobbyListener listener);
+
+ public GameInfo getGameInfo(String string);
}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/LobbyFactory.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/LobbyFactory.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/LobbyFactory.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.lobby;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javolution.util.FastMap;
+
+import org.p2play.lobby.impl.LobbyApplication;
+
+import rice.p2p.commonapi.Endpoint;
+import rice.p2p.commonapi.Node;
+import rice.p2p.commonapi.NodeHandle;
+
+public class LobbyFactory {
+ private Node node;
+
+ private Map<String, Endpoint> endpointMap;
+
+ public LobbyFactory(Node node) {
+ super();
+ this.node = node;
+ endpointMap = new FastMap<String, Endpoint>();
+ }
+
+ public LobbyServerSocket createServerSocket(String name) throws IOException {
+ Endpoint endpoint = node.buildEndpoint(new LobbyApplication(), name);
+
+ LobbyServerSocket serverSocket = new LobbyServerSocket(endpoint);
+
+ endpoint.accept(serverSocket);
+
+ endpoint.register();
+
+ endpointMap.put(name, endpoint);
+
+ return serverSocket;
+ }
+
+ public LobbySocket createSocket(String name, NodeHandle handle) throws IOException {
+ Endpoint endpoint = endpointMap.get(name);
+
+ if (endpoint == null) {
+ endpoint=node.buildEndpoint(new LobbyApplication(), "test");
+
+ endpoint.register();
+ endpointMap.put(name, endpoint);
+ }
+ LobbySocket lobbySocket = new LobbySocket(endpoint, handle);
+
+ return lobbySocket;
+ }
+}
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/LobbyListener.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/LobbyListener.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/LobbyListener.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby;
public interface LobbyListener {
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby;
import java.io.IOException;
@@ -4,6 +22,7 @@
import java.net.ServerSocket;
import java.net.Socket;
+import rice.p2p.commonapi.Endpoint;
import rice.p2p.commonapi.appsocket.AppSocket;
import rice.p2p.commonapi.appsocket.AppSocketReceiver;
@@ -13,8 +32,11 @@
private LobbySocket lobbySocket;
- public LobbyServerSocket() throws IOException {
+ private Endpoint endpoint;
+
+ public LobbyServerSocket(Endpoint endpoint) throws IOException {
super();
+ this.endpoint=endpoint;
}
public void receiveException(AppSocket socket, Exception e) {
@@ -36,6 +58,7 @@
e.printStackTrace();
}
socket.register(true, true, 30000, lobbySocket);
+ endpoint.accept(this);
mutex.notifyAll();
}
@@ -54,4 +77,8 @@
return lobbySocket;
}
}
+
+ public Endpoint getEndpoint() {
+ return endpoint;
+ }
}
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby;
import java.io.IOException;
@@ -5,8 +23,10 @@
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import java.net.InetAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
+import java.util.Random;
import rice.p2p.commonapi.Endpoint;
import rice.p2p.commonapi.NodeHandle;
@@ -27,6 +47,8 @@
private AppSocket socket;
+ private InetAddress address;
+
public LobbySocket() throws IOException {
buffer = new ByteBuffer[2];
buffer[0] = ByteBuffer.wrap(new byte[1024]);
@@ -38,6 +60,12 @@
outputStream = new PipedOutputStream();
pipedInputStream = new PipedInputStream(
(PipedOutputStream) outputStream);
+
+ Random random=new Random();
+
+ byte[] b=new byte[4];
+ random.nextBytes(b);
+ address=InetAddress.getByAddress(b);
}
public LobbySocket(Endpoint endpoint, NodeHandle handle) throws IOException {
@@ -54,11 +82,13 @@
boolean canWrite) {
try {
if (canRead) {
- socket.read(buffer, 0, 1);
+ long i=socket.read(buffer, 0, 1);
pipedOutputStream.write(buffer[0].array(),
- buffer[0].position(), buffer[0].remaining());
+ 0, (int)i);
pipedOutputStream.flush();
buffer[0].rewind();
+
+ System.out.println("Read: "+i);
}
if (canWrite && pipedInputStream.available() > 0) {
@@ -66,9 +96,9 @@
pipedInputStream.read(b);
buffer[1] = ByteBuffer.wrap(b);
long i=socket.write(buffer, 1, 1);
+
System.out.println("Wrote: "+i);
- socket.shutdownOutput();
- }
+ }
socket.register(true, true, 30000, this);
} catch (Exception e) {
@@ -78,6 +108,7 @@
public void receiveSocket(AppSocket socket) {
this.socket=socket;
+ socket.register(true, true, 30000, this);
}
@Override
@@ -94,4 +125,9 @@
public synchronized void close() throws IOException {
socket.close();
}
+
+ @Override
+ public InetAddress getInetAddress() {
+ return address;
+ }
}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyApplication.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyApplication.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyApplication.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.lobby.impl;
+
+import rice.p2p.commonapi.Application;
+import rice.p2p.commonapi.Id;
+import rice.p2p.commonapi.Message;
+import rice.p2p.commonapi.NodeHandle;
+import rice.p2p.commonapi.RouteMessage;
+
+public class LobbyApplication implements Application {
+
+ public void deliver(Id id, Message message) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean forward(RouteMessage message) {
+ return true;
+ }
+
+ public void update(NodeHandle handle, boolean joined) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby.impl;
import java.io.IOException;
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyMessage.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyMessage.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyMessage.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,5 +1,28 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby.impl;
-public interface LobbyMessage {
+import java.io.Serializable;
+
+import rice.p2p.commonapi.Message;
+import rice.p2p.scribe.ScribeContent;
+
+public interface LobbyMessage extends Message, ScribeContent, Serializable{
public static final short TYPE_PUBLISH_GAME=1;
}
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby.impl;
import java.io.IOException;
@@ -8,10 +26,8 @@
import rice.p2p.commonapi.Endpoint;
import rice.p2p.commonapi.rawserialization.InputBuffer;
import rice.p2p.commonapi.rawserialization.OutputBuffer;
-import rice.p2p.commonapi.rawserialization.RawMessage;
-import rice.p2p.scribe.rawserialization.RawScribeContent;
-public class PublishGameInfoMessage implements RawMessage,RawScribeContent,LobbyMessage {
+public class PublishGameInfoMessage implements LobbyMessage {
private GameInfo gameInfo;
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/impl/ScribeLobby.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/ScribeLobby.java 2007-03-20 12:28:02 UTC (rev 51)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/ScribeLobby.java 2007-03-23 20:23:47 UTC (rev 52)
@@ -1,7 +1,28 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.lobby.impl;
+import java.util.Map;
+
import javolution.util.FastCollection;
import javolution.util.FastList;
+import javolution.util.FastMap;
import javolution.util.FastCollection.Record;
import org.p2play.lobby.GameInfo;
@@ -21,7 +42,7 @@
import rice.p2p.scribe.ScribeImpl;
import rice.p2p.scribe.Topic;
-public class ScribeLobby implements Lobby, Application, ScribeClient {
+public class ScribeLobby implements Lobby, Application, ScribeClient, LobbyListener {
private FastCollection<LobbyListener> listeners;
@@ -32,16 +53,19 @@
private Endpoint endpoint;
private Topic topic;
+
+ private Map<String, GameInfo> gameInfoMap;
public ScribeLobby(Node node) {
-
listeners=new FastList<LobbyListener>();
+ this.addLobbyListener(this);
publishedGames=new FastList<GameInfo>();
+ gameInfoMap=new FastMap<String, GameInfo>();
endpoint=node.buildEndpoint(this, "lobby_endpoint");
- LobbyDeserializer deserializer=new LobbyDeserializer(endpoint);
- endpoint.setDeserializer(deserializer);
+ //LobbyDeserializer deserializer=new LobbyDeserializer(endpoint);
+ //endpoint.setDeserializer(deserializer);
scribe=new ScribeImpl(node,"lobby_scribe");
- scribe.setContentDeserializer(deserializer);
+ //scribe.setContentDeserializer(deserializer);
topic=new Topic(node.getIdFactory(),"lobby_toppc");
endpoint.register();
@@ -60,10 +84,22 @@
publishedGames.remove(gameInfo);
}
- public void publishGame(GameInfo gameInfo) {
+ public void publishGame(final GameInfo gameInfo) {
publishedGames.add(gameInfo);
- scribe.publish(topic, new PublishGameInfoMessage(gameInfo));
+ //for now republish every 5 seconds
+ new Thread(new Runnable(){public void run() {
+ while (true) {
+ scribe.publish(topic, new PublishGameInfoMessage(gameInfo));
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }}).start();
}
public void deliver(Id id, Message message) {
@@ -119,5 +155,15 @@
}
+ public void gameCreated(GameInfo gameInfo) {
+ gameInfoMap.put(gameInfo.getName(), gameInfo);
+ System.out.println(gameInfo+" created.");
+ }
+ public void gameRemoved(GameInfo gameInfo) {
+ gameInfoMap.remove(gameInfo.getName());
+ }
+ public GameInfo getGameInfo(String name) {
+ return gameInfoMap.get(name);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:28:05
|
Revision: 51
http://p2play.svn.sourceforge.net/p2play/?rev=51&view=rev
Author: tisoft
Date: 2007-03-20 05:28:02 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Removed Paths:
-------------
trunk/P2PlayAdmin/.settings/org.eclipse.wst.validation.prefs
Property Changed:
----------------
P2PlayLegacy/
trunk/P2PlayAdmin/
Property changes on: P2PlayLegacy
___________________________________________________________________
Name: svn:ignore
+ bin
Property changes on: trunk/P2PlayAdmin
___________________________________________________________________
Name: svn:ignore
- target
tomcat
+ target
tomcat
*.gwt-cache
Deleted: trunk/P2PlayAdmin/.settings/org.eclipse.wst.validation.prefs
===================================================================
--- trunk/P2PlayAdmin/.settings/org.eclipse.wst.validation.prefs 2007-03-20 12:17:08 UTC (rev 50)
+++ trunk/P2PlayAdmin/.settings/org.eclipse.wst.validation.prefs 2007-03-20 12:28:02 UTC (rev 51)
@@ -1,6 +0,0 @@
-#Fri Jan 19 13:22:55 CET 2007
-DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator;
-USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.common.componentcore.internal.ModuleCoreValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;
-USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.html.internal.validation.HTMLValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.wst.common.componentcore.internal.ModuleCoreValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;
-USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.1.2.v200610162137
-eclipse.preferences.version=1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:25:29
|
Revision: 49
http://p2play.svn.sourceforge.net/p2play/?rev=49&view=rev
Author: tisoft
Date: 2007-03-20 05:16:16 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
P2PlayLegacy/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:25:28
|
Revision: 48
http://p2play.svn.sourceforge.net/p2play/?rev=48&view=rev
Author: tisoft
Date: 2007-03-20 05:15:38 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
added license information
Modified Paths:
--------------
trunk/P2Play/src/main/java/org/p2play/security/Signable.java
trunk/P2Play/src/main/java/org/p2play/security/SignablePublicKey.java
trunk/P2Play/src/main/java/org/p2play/security/Signature.java
Modified: trunk/P2Play/src/main/java/org/p2play/security/Signable.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/security/Signable.java 2007-03-20 12:11:17 UTC (rev 47)
+++ trunk/P2Play/src/main/java/org/p2play/security/Signable.java 2007-03-20 12:15:38 UTC (rev 48)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.security;
Modified: trunk/P2Play/src/main/java/org/p2play/security/SignablePublicKey.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/security/SignablePublicKey.java 2007-03-20 12:11:17 UTC (rev 47)
+++ trunk/P2Play/src/main/java/org/p2play/security/SignablePublicKey.java 2007-03-20 12:15:38 UTC (rev 48)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.security;
Modified: trunk/P2Play/src/main/java/org/p2play/security/Signature.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/security/Signature.java 2007-03-20 12:11:17 UTC (rev 47)
+++ trunk/P2Play/src/main/java/org/p2play/security/Signature.java 2007-03-20 12:15:38 UTC (rev 48)
@@ -1,3 +1,21 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.p2play.security;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:25:28
|
Revision: 45
http://p2play.svn.sourceforge.net/p2play/?rev=45&view=rev
Author: tisoft
Date: 2007-03-20 05:08:01 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
changes for maven
Modified Paths:
--------------
trunk/P2PlayAdmin/.classpath
trunk/P2PlayAdmin/.project
trunk/P2PlayAdmin/.settings/org.eclipse.jst.common.project.facet.core.prefs
trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.component
trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.project.facet.core.xml
Added Paths:
-----------
trunk/P2PlayAdmin/pom.xml
Modified: trunk/P2PlayAdmin/.classpath
===================================================================
--- trunk/P2PlayAdmin/.classpath 2007-03-20 12:07:00 UTC (rev 44)
+++ trunk/P2PlayAdmin/.classpath 2007-03-20 12:08:01 UTC (rev 45)
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.5.0 (MacOS X Default)"/>
- <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5"/>
- <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
- <classpathentry kind="var" path="GWT_HOME/gwt-user.jar"/>
- <classpathentry kind="output" path="build/classes"/>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="src/main/resources" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: trunk/P2PlayAdmin/.project
===================================================================
--- trunk/P2PlayAdmin/.project 2007-03-20 12:07:00 UTC (rev 44)
+++ trunk/P2PlayAdmin/.project 2007-03-20 12:08:01 UTC (rev 45)
@@ -3,7 +3,6 @@
<name>P2PlayAdmin</name>
<comment></comment>
<projects>
- <project>P2Play</project>
<project>P2PlayBoot</project>
<project>Servers</project>
</projects>
@@ -14,6 +13,11 @@
</arguments>
</buildCommand>
<buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -33,14 +37,8 @@
<nature>com.googlipse.gwt.gwtNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
</natures>
- <linkedResources>
- <link>
- <name>WebContent/WEB-INF/lib/gwt-servlet.jar</name>
- <type>1</type>
- <locationURI>GWT_HOME/gwt-servlet.jar</locationURI>
- </link>
- </linkedResources>
</projectDescription>
Modified: trunk/P2PlayAdmin/.settings/org.eclipse.jst.common.project.facet.core.prefs
===================================================================
--- trunk/P2PlayAdmin/.settings/org.eclipse.jst.common.project.facet.core.prefs 2007-03-20 12:07:00 UTC (rev 44)
+++ trunk/P2PlayAdmin/.settings/org.eclipse.jst.common.project.facet.core.prefs 2007-03-20 12:08:01 UTC (rev 45)
@@ -1,4 +1,4 @@
-#Tue Jan 16 22:00:18 CET 2007
+#Tue Mar 20 08:43:01 CET 2007
classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.launching.macosx.MacOSXType\:\:JVM\ 1.5.0\ (MacOS\ X\ Default)/owners=jst.java\:5.0
-classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v5.5/owners=jst.web\:2.4
+classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:_sw_var_tomcat5/owners=jst.web\:2.4
eclipse.preferences.version=1
Modified: trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.component
===================================================================
--- trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.component 2007-03-20 12:07:00 UTC (rev 44)
+++ trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.component 2007-03-20 12:08:01 UTC (rev 45)
@@ -1,40 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="P2PlayAdmin">
-<wb-resource deploy-path="/" source-path="/WebContent"/>
-<wb-resource deploy-path="/" source-path="/build/gwtOutput"/>
-<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/P2Play/P2Play">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2Play/lib/pnuts.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2Play/lib/jdom.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2Play/lib/javolution.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/P2PlayBoot/P2PlayBoot">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2PlayBoot/lib/commons-vfs-20070107.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2PlayBoot/lib/commons-logging-1.1.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2PlayBoot/lib/xstream-1.1.3.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2PlayBoot/lib/xpp3-1.1.3.4d_b2.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/P2PlayBoot/lib/FreePastry.jar">
-<dependency-type>uses</dependency-type>
-</dependent-module>
-<property name="context-root" value="P2PlayAdmin"/>
-<property name="java-output-path" value="build/classes"/>
+<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
+<property name="context-root" value="/P2PlayAdmin"/>
</wb-module>
</project-modules>
Modified: trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
--- trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.project.facet.core.xml 2007-03-20 12:07:00 UTC (rev 44)
+++ trunk/P2PlayAdmin/.settings/org.eclipse.wst.common.project.facet.core.xml 2007-03-20 12:08:01 UTC (rev 45)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
- <runtime name="Apache Tomcat v5.5"/>
<fixed facet="jst.java"/>
<fixed facet="jst.web"/>
<installed facet="jst.web" version="2.4"/>
Added: trunk/P2PlayAdmin/pom.xml
===================================================================
--- trunk/P2PlayAdmin/pom.xml (rev 0)
+++ trunk/P2PlayAdmin/pom.xml 2007-03-20 12:08:01 UTC (rev 45)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>P2PlayAdmin</groupId>
+ <artifactId>P2PlayAdmin</artifactId>
+ <packaging>war</packaging>
+ <version>0.0.1</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.totsp.gwt</groupId>
+ <artifactId>maven-googlewebtoolkit2-plugin</artifactId>
+ <version>1.5.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>mergewebxml</goal>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <logLevel>ALL</logLevel>
+ <runTarget>
+ org.p2play.web.vfs.VFS/VFS.html
+ </runTarget>
+ <compileTarget>
+ org.p2play.web.vfs.VFS
+ </compileTarget>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>gwt-maven</id>
+ <url>
+ http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/
+ </url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-user</artifactId>
+ <version>1.3.3</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-servlet</artifactId>
+ <version>1.3.3</version>
+ </dependency>
+ <dependency>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayService</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+</project>
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:25:28
|
Revision: 47
http://p2play.svn.sourceforge.net/p2play/?rev=47&view=rev
Author: tisoft
Date: 2007-03-20 05:11:17 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
changes for maven
Property Changed:
----------------
trunk/P2PlayAdmin/
Property changes on: trunk/P2PlayAdmin
___________________________________________________________________
Name: svn:ignore
+ target
tomcat
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:25:27
|
Revision: 50
http://p2play.svn.sourceforge.net/p2play/?rev=50&view=rev
Author: tisoft
Date: 2007-03-20 05:17:08 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
P2PlayLegacy/.classpath
P2PlayLegacy/.project
P2PlayLegacy/readme.txt
P2PlayLegacy/src/
P2PlayLegacy/src/de/
P2PlayLegacy/src/de/upb/
P2PlayLegacy/src/de/upb/mmog/
P2PlayLegacy/src/de/upb/mmog/net/
P2PlayLegacy/src/de/upb/mmog/net/data/
P2PlayLegacy/src/de/upb/mmog/net/data/AbstractData.java
P2PlayLegacy/src/de/upb/mmog/net/data/DataContainerImpl.java
P2PlayLegacy/src/de/upb/mmog/net/data/DataPastContent.java
P2PlayLegacy/src/de/upb/mmog/net/data/DummyDataManager.java
P2PlayLegacy/src/de/upb/mmog/net/data/GameStateData.java
P2PlayLegacy/src/de/upb/mmog/net/data/PastDataManager.java
P2PlayLegacy/src/de/upb/mmog/net/data/StringData.java
P2PlayLegacy/src/de/upb/mmog/net/region/
P2PlayLegacy/src/de/upb/mmog/net/region/impl/
P2PlayLegacy/src/de/upb/mmog/net/region/impl/DummyClient.java
P2PlayLegacy/src/de/upb/mmog/net/region/impl/GameRegion.java
P2PlayLegacy/src/de/upb/mmog/net/region/impl/GroupedDynamicRegionManager.java
P2PlayLegacy/src/de/upb/mmog/net/region/impl/GroupedStaticNetworkRegionManager.java
P2PlayLegacy/src/de/upb/mmog/net/region/impl/ObjectGameAction.java
P2PlayLegacy/src/de/upb/mmog/net/region/impl/PeerToPeerRegionManager.java
P2PlayLegacy/src/de/upb/mmog/net/resource/
P2PlayLegacy/src/de/upb/mmog/net/resource/PastResourceManager.java
P2PlayLegacy/src/de/upb/mmog/net/security/
P2PlayLegacy/src/de/upb/mmog/net/security/AccessControlManager.java
P2PlayLegacy/src/de/upb/mmog/net/security/KeyManager.java
P2PlayLegacy/src/de/upb/mmog/net/security/SignableKeyPair.java
P2PlayLegacy/src/de/upb/mmog/net/security/impl/
P2PlayLegacy/src/de/upb/mmog/net/security/impl/CAKeyManager.java
P2PlayLegacy/src/de/upb/mmog/net/security/impl/DummyAccessControlManager.java
P2PlayLegacy/src/de/upb/mmog/net/security/impl/DummyKeyManager.java
P2PlayLegacy/src/de/upb/mmog/net/security/impl/ScribeKeyManager.java
P2PlayLegacy/src/de/upb/mmog/net/security/impl/ScribeKeyRequestMessage.java
P2PlayLegacy/src/de/upb/mmog/net/security/impl/ScribeKeyResponseMessage.java
P2PlayLegacy/src/de/upb/mmog/net/security/impl/SecurityUtils.java
P2PlayLegacy/src/de/upb/mmog/net/test/
P2PlayLegacy/src/de/upb/mmog/net/test/DummyGameState.java
P2PlayLegacy/src/de/upb/mmog/net/test/debug/
P2PlayLegacy/src/de/upb/mmog/net/test/debug/DebugClient.java
P2PlayLegacy/src/de/upb/mmog/net/test/debug/PastDebugDialog.java
P2PlayLegacy/src/de/upb/mmog/net/test/gui/
P2PlayLegacy/src/de/upb/mmog/net/test/gui/logon/
P2PlayLegacy/src/de/upb/mmog/net/test/gui/logon/ConnectDialog.java
P2PlayLegacy/src/de/upb/mmog/net/test/gui/past/
P2PlayLegacy/src/de/upb/mmog/net/test/gui/past/PastInsertRetrieveDialog.java
P2PlayLegacy/src/de/upb/mmog/net/test/gui/region/
P2PlayLegacy/src/de/upb/mmog/net/test/gui/region/RegionDialog.java
P2PlayLegacy/src/de/upb/mmog/net/test/gui/util/
P2PlayLegacy/src/de/upb/mmog/net/test/gui/util/HistoryManager.java
P2PlayLegacy/src/de/upb/mmog/net/test/gui/util/JComboBoxWithHistory.java
P2PlayLegacy/src/de/upb/mmog/net/test/vfs/
P2PlayLegacy/src/de/upb/mmog/net/test/vfs/Test.java
Added: P2PlayLegacy/.classpath
===================================================================
--- P2PlayLegacy/.classpath (rev 0)
+++ P2PlayLegacy/.classpath 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/P2Play"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: P2PlayLegacy/.project
===================================================================
--- P2PlayLegacy/.project (rev 0)
+++ P2PlayLegacy/.project 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>P2PlayLegacy</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: P2PlayLegacy/readme.txt
===================================================================
--- P2PlayLegacy/readme.txt (rev 0)
+++ P2PlayLegacy/readme.txt 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,3 @@
+This project contains the old source files from the project group at University of Paderborn. They will be moved to the other projects, and this project will be removed then.
+
+They are all licensed under the GNU Lesser General Public License.
\ No newline at end of file
Added: P2PlayLegacy/src/de/upb/mmog/net/data/AbstractData.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/data/AbstractData.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/data/AbstractData.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,77 @@
+package de.upb.mmog.net.data;
+
+import org.p2play.data.Data;
+import org.p2play.security.Signature;
+
+/**
+ * Abstract super-class for Data Objects.
+ * implements Signature handling
+ */
+public abstract class AbstractData implements Data {
+
+ private String identifier;
+
+ private Signature[] signatures;
+
+
+
+ /**
+ * Constructor for AbstractData.
+ * @param identifier String
+ */
+ public AbstractData(String identifier) {
+ super();
+ this.identifier = identifier;
+ signatures=new Signature[0];
+ }
+
+ /**
+ * Method getIdentifier.
+ * @return String
+ * @see org.p2play.data.Data#getIdentifier()
+ */
+ public final String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * Method getVersion.
+ * @return int
+ * @see org.p2play.data.Data#getVersion()
+ */
+ public abstract int getVersion();
+
+ /**
+ * Method getSignatures.
+ * @return Signature[]
+ * @see de.upb.mmog.net.security.Signed#getSignatures()
+ */
+ public final Signature[] getSignatures() {
+ return signatures;
+ }
+
+ /**
+ * Method getData.
+ * @return byte[]
+ * @see de.upb.mmog.net.security.Signed#getData()
+ */
+ public abstract byte[] getData();
+
+ /**
+ * Method addSignature.
+ * @param signature Signature
+ * @see de.upb.mmog.net.security.Signable#addSignature(Signature)
+ */
+ public final void addSignature(Signature signature) {
+ synchronized (signatures) {
+ Signature[] newSignatures = new Signature[signatures.length + 1];
+ System
+ .arraycopy(signatures, 0, newSignatures, 0,
+ signatures.length);
+ newSignatures[signatures.length] = signature;
+
+ signatures=newSignatures;
+ }
+ }
+
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/data/DataContainerImpl.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/data/DataContainerImpl.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/data/DataContainerImpl.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,120 @@
+package de.upb.mmog.net.data;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.p2play.data.Data;
+import org.p2play.data.DataContainer;
+import org.p2play.data.DataListener;
+
+import rice.Continuation;
+
+public class DataContainerImpl implements Continuation, DataContainer {
+ private Data data;
+
+ private String name;
+
+ private List<DataListener> listeners = new LinkedList<DataListener>();
+
+ private Exception exception;
+
+ public DataContainerImpl(String name) {
+ this.name = name;
+ }
+
+ DataContainerImpl(Data data) {
+ this(data.getIdentifier());
+ this.data = data;
+ }
+
+ /* (non-Javadoc)
+ * @see org.p2play.data.impl.DataContainer#getData()
+ */
+ public Data getData() {
+ if (exception != null) {
+ throw new RuntimeException(exception);
+ }
+ return data;
+ }
+
+ /* (non-Javadoc)
+ * @see org.p2play.data.impl.DataContainer#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ void setData(Data data) {
+ this.data = data;
+ this.exception = null;
+ notifyListeners();
+ }
+
+ void setException(Exception exception) {
+ this.data = null;
+ this.exception = exception;
+ notifyListeners();
+ }
+
+ /* (non-Javadoc)
+ * @see org.p2play.data.impl.DataContainer#getException()
+ */
+ public Exception getException() {
+ return exception;
+ }
+
+ /* (non-Javadoc)
+ * @see org.p2play.data.impl.DataContainer#isReady()
+ */
+ public boolean isReady() {
+ return data != null || exception != null;
+ }
+
+ public void receiveResult(Object result) {
+ if (result != null) {
+ setData(((DataPastContent) result).getData());
+ } else {
+ setData(null);
+ }
+ }
+
+ public void receiveException(Exception result) {
+ setException(result);
+ result.printStackTrace();
+ }
+
+ /* (non-Javadoc)
+ * @see org.p2play.data.impl.DataContainer#removeDataListener(org.p2play.data.DataListener)
+ */
+ public void removeDataListener(DataListener listener) {
+ synchronized (listeners) {
+ listeners.remove(listener);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.p2play.data.impl.DataContainer#addDataListener(org.p2play.data.DataListener)
+ */
+ public void addDataListener(DataListener listener) {
+ synchronized (listeners) {
+ listeners.add(listener);
+ }
+ }
+
+ private void notifyListeners() {
+ synchronized (listeners) {
+
+ Iterator<DataListener> iterator = listeners.iterator();
+ while (iterator.hasNext()) {
+ DataListener listener = iterator.next();
+
+ if (exception != null) {
+ listener.dataException(this);
+ } else {
+ listener.dataUpdated(this);
+ }
+ }
+ }
+ }
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/data/DataPastContent.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/data/DataPastContent.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/data/DataPastContent.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,173 @@
+package de.upb.mmog.net.data;
+
+import org.p2play.data.Data;
+
+import rice.p2p.commonapi.Id;
+import rice.p2p.commonapi.NodeHandle;
+import rice.p2p.past.Past;
+import rice.p2p.past.PastContent;
+import rice.p2p.past.PastContentHandle;
+import rice.p2p.past.PastException;
+import rice.p2p.past.gc.GCPast;
+import rice.p2p.past.gc.GCPastContent;
+import rice.p2p.past.gc.GCPastContentHandle;
+import rice.p2p.past.gc.GCPastMetadata;
+import rice.p2p.scribe.ScribeContent;
+import de.upb.mmog.net.security.AccessControlManager;
+
+/**
+ */
+public class DataPastContent implements GCPastContent, ScribeContent {
+
+ private Id id;
+
+ private Data data;
+
+ private long version = 0;
+
+ private long expiration;
+
+ /**
+ * Constructor for DataPastContent.
+ * @param id Id
+ * @param data Data
+ * @param version long
+ * @param expiration long
+ */
+ public DataPastContent(Id id, Data data, long version,
+ long expiration) {
+ super();
+ this.id = id;
+ this.data=data;
+ this.version = version;
+ this.expiration = expiration;
+ }
+
+ /**
+ * Constructor for DataPastContent.
+ * @param id Id
+ * @param data Data
+ */
+ public DataPastContent(Id id, Data data) {
+ this(id, data, 0,
+ GCPast.INFINITY_EXPIRATION);
+ }
+
+ /**
+ * Method getData.
+ * @return Data
+ */
+ public Data getData() {
+ return data;
+ }
+
+ /**
+ * Method getVersion.
+ * @return long
+ * @see rice.p2p.past.gc.GCPastContent#getVersion()
+ */
+ public long getVersion() {
+ return version;
+ }
+
+ /**
+ * Method getHandle.
+ * @param local GCPast
+ * @param expiration long
+ * @return GCPastContentHandle
+ * @see rice.p2p.past.gc.GCPastContent#getHandle(GCPast, long)
+ */
+ public GCPastContentHandle getHandle(final GCPast local, final long expiration) {
+ final NodeHandle handle=local.getLocalNodeHandle();
+ return new GCPastContentHandle() {
+ public Id getId() {
+ return DataPastContent.this.getId();
+ }
+ public NodeHandle getNodeHandle() {
+ return handle;
+ }
+ public long getExpiration() {
+ return expiration;
+ }
+ public long getVersion() {
+ return DataPastContent.this.getVersion();
+ }
+ };
+ }
+
+ /**
+ * Method getMetadata.
+ * @param expiration long
+ * @return GCPastMetadata
+ * @see rice.p2p.past.gc.GCPastContent#getMetadata(long)
+ */
+ public GCPastMetadata getMetadata(long expiration) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Method checkInsert.
+ * @param id Id
+ * @param existingContent PastContent
+ * @return PastContent
+ * @throws PastException
+ * @see rice.p2p.past.PastContent#checkInsert(Id, PastContent)
+ */
+ public PastContent checkInsert(Id id, PastContent existingContent)
+ throws PastException {
+
+ if(AccessControlManager.getAccessControlManager().checkAccess(getData(),getData().getIdentifier())){
+ return this;
+ }
+ else
+ {
+ throw new PastException("Access denied for "+data.getIdentifier());
+ }
+ }
+
+ /**
+ * Method getHandle.
+ * @param local Past
+ * @return PastContentHandle
+ * @see rice.p2p.past.PastContent#getHandle(Past)
+ */
+ public PastContentHandle getHandle(final Past local) {
+ final NodeHandle handle=local.getLocalNodeHandle();
+ return new PastContentHandle() {
+ public Id getId() {
+ return DataPastContent.this.getId();
+ }
+ public NodeHandle getNodeHandle() {
+ return handle;
+ }
+ };
+ }
+
+ /**
+ * Method getId.
+ * @return Id
+ * @see rice.p2p.past.PastContent#getId()
+ */
+ public Id getId() {
+ return id;
+ }
+
+ /**
+ * Method isMutable.
+ * @return boolean
+ * @see rice.p2p.past.PastContent#isMutable()
+ */
+ public boolean isMutable() {
+ return true;
+ }
+
+ /**
+ * Method getExpiration.
+ * @return long
+ */
+ public long getExpiration() {
+ return expiration;
+ }
+
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/data/DummyDataManager.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/data/DummyDataManager.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/data/DummyDataManager.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,47 @@
+package de.upb.mmog.net.data;
+
+import java.util.HashMap;
+
+import org.p2play.data.Data;
+import org.p2play.data.DataContainer;
+import org.p2play.data.DataListener;
+import org.p2play.data.DataManager;
+
+/**
+ * A dummy Data Manager, that stores all data in a local HashMap.
+ */
+public class DummyDataManager implements DataManager {
+
+ private static HashMap<String,DataContainerImpl> hashMap=new HashMap<String,DataContainerImpl>();
+
+ /**
+ * Method loadData.
+ * @param identifier String
+ * @return Data
+ * @see org.p2play.data.DataManager#loadData(String)
+ */
+ public DataContainer loadData(String identifier) {
+ return hashMap.get(identifier);
+ }
+
+ /**
+ * Method storeData.
+ * @param data Data
+ * @see org.p2play.data.DataManager#storeData(Data)
+ */
+ public void storeData(Data data) {
+ DataContainerImpl dataContainerImpl=hashMap.get(data.getIdentifier());
+ if(dataContainerImpl==null){
+ dataContainerImpl=new DataContainerImpl(data);
+ hashMap.put(data.getIdentifier(), dataContainerImpl);
+ }
+ else{
+ dataContainerImpl.setData(data);
+ }
+ }
+
+ public DataContainer loadData(String identifier, DataListener listener) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/data/GameStateData.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/data/GameStateData.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/data/GameStateData.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,40 @@
+package de.upb.mmog.net.data;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import org.p2play.region.GameState;
+
+public class GameStateData extends AbstractData{
+
+ private GameState gameState;
+
+ public GameStateData(String identifier, GameState gameState) {
+ super(identifier);
+ this.gameState=gameState;
+ }
+
+
+ @Override
+ public int getVersion() {
+ return 0;
+ }
+
+ @Override
+ public byte[] getData() {
+ ByteArrayOutputStream bos=new ByteArrayOutputStream();
+
+ try {
+ new ObjectOutputStream(bos).writeObject(gameState);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return bos.toByteArray();
+ }
+
+ public GameState getGameState() {
+ return gameState;
+ }
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/data/PastDataManager.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/data/PastDataManager.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/data/PastDataManager.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,350 @@
+package de.upb.mmog.net.data;
+
+
+import java.util.HashMap;
+
+import org.p2play.data.Data;
+import org.p2play.data.DataContainer;
+import org.p2play.data.DataListener;
+import org.p2play.data.DataManager;
+import org.p2play.security.SignablePublicKey;
+
+import rice.Continuation;
+import rice.environment.logging.Logger;
+import rice.p2p.commonapi.Id;
+import rice.p2p.commonapi.NodeHandle;
+import rice.p2p.past.Past;
+import rice.p2p.scribe.Scribe;
+import rice.p2p.scribe.ScribeClient;
+import rice.p2p.scribe.ScribeContent;
+import rice.p2p.scribe.Topic;
+import rice.pastry.commonapi.PastryIdFactory;
+
+/**
+ * A Data Manager that stores Data in the Past network
+ */
+public class PastDataManager implements DataManager, ScribeClient {
+ private Past past;
+
+ private Scribe scribe;
+
+ private HashMap<String, DataContainerImpl> dataMap;
+
+ private Logger logger;
+
+ /**
+ * Constructor for PastDataManager.
+ *
+ * @param id
+ * Id
+ * @param past
+ * Past
+ * @param scribe
+ * Scribe
+ * @param keyManager
+ * KeyManager
+ * @param accessControlManager
+ * AccessControlManager
+ */
+ public PastDataManager(Id id, Past past, Scribe scribe) {
+ super();
+
+ this.logger = past.getEnvironment().getLogManager().getLogger(
+ PastDataManager.class, "");
+
+ this.past = past;
+ this.scribe = scribe;
+
+ this.dataMap = new HashMap<String, DataContainerImpl>();
+ }
+
+ /**
+ * Method loadData.
+ *
+ * @param identifier
+ * String
+ * @return Data
+ * @see org.p2play.data.DataManager#loadData(String)
+ */
+ public DataContainer loadData(String identifier) {
+
+ DataContainerImpl container = dataMap.get(identifier);
+ if (container == null) {
+ container = new DataContainerImpl(identifier);
+
+ final Id lookupKey = new PastryIdFactory(past.getEnvironment())
+ .buildId(identifier);
+
+ // subcribe to the scribe topic for this data
+ scribe.subscribe(getTopic(identifier), this);
+
+ past.lookup(lookupKey, container);
+
+ }
+ return container;
+ }
+
+ public DataContainer loadData(String identifier, DataListener listener) {
+ DataContainer container = loadData(identifier);
+ container.addDataListener(listener);
+ return container;
+ }
+
+ /**
+ * Method storeData.
+ *
+ * @param data
+ * Data
+ * @see org.p2play.data.DataManager#storeData(Data)
+ */
+ public void storeData(Data data) {
+ DataContainerImpl dataContainerImpl = dataMap.get(data.getIdentifier());
+
+ if (dataContainerImpl == null) {
+ dataContainerImpl = new DataContainerImpl(data);
+
+ // subcribe to the scribe topic for this data
+ scribe.subscribe(getTopic(data.getIdentifier()), this);
+
+ dataMap.put(data.getIdentifier(), dataContainerImpl);
+ } else {
+ dataContainerImpl.setData(data);
+ }
+
+ final Id lookupKey = new PastryIdFactory(past.getEnvironment())
+ .buildId(data.getIdentifier());
+
+ // send the signature of the data as multicast into the scribe group
+ scribe.publish(getTopic(data.getIdentifier()), new DataPastContent(
+ lookupKey, data));
+
+ past.insert(new DataPastContent(lookupKey, data), new Continuation() {
+ public void receiveException(Exception result) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void receiveResult(Object result) {
+ };
+ });
+ }
+
+ /**
+ * Method getTopic.
+ *
+ * @param name
+ * String
+ * @return Topic
+ */
+ private Topic getTopic(String name) {
+ return new Topic(new PastryIdFactory(scribe.getEnvironment()),
+ "past.data." + name);
+ }
+
+ /**
+ * Method anycast.
+ *
+ * @param topic
+ * Topic
+ * @param content
+ * ScribeContent
+ * @return boolean
+ * @see rice.p2p.scribe.ScribeClient#anycast(Topic, ScribeContent)
+ */
+ public boolean anycast(Topic topic, ScribeContent content) {
+ return false;
+ }
+
+ /**
+ * Method deliver.
+ *
+ * @param topic
+ * Topic
+ * @param content
+ * ScribeContent
+ * @see rice.p2p.scribe.ScribeClient#deliver(Topic, ScribeContent)
+ */
+ public void deliver(Topic topic, ScribeContent content) {
+ if (content instanceof DataPastContent) {
+ DataPastContent response = (DataPastContent) content;
+
+ DataContainerImpl container = dataMap.get(response.getData()
+ .getIdentifier());
+ if (container == null) {
+ container = new DataContainerImpl(response.getData());
+ dataMap.put(container.getName(), container);
+ } else {
+ container.setData(response.getData());
+ }
+ }
+
+ }
+
+ /**
+ * Method childAdded.
+ *
+ * @param topic
+ * Topic
+ * @param child
+ * NodeHandle
+ * @see rice.p2p.scribe.ScribeClient#childAdded(Topic, NodeHandle)
+ */
+ public void childAdded(Topic topic, NodeHandle child) {
+ logger.log("Added child " + child + " to " + topic);
+ }
+
+ /**
+ * Method childRemoved.
+ *
+ * @param topic
+ * Topic
+ * @param child
+ * NodeHandle
+ * @see rice.p2p.scribe.ScribeClient#childRemoved(Topic, NodeHandle)
+ */
+ public void childRemoved(Topic topic, NodeHandle child) {
+ logger.log("Removed child " + child + " from " + topic);
+ }
+
+ /**
+ * Method subscribeFailed.
+ *
+ * @param topic
+ * Topic
+ * @see rice.p2p.scribe.ScribeClient#subscribeFailed(Topic)
+ */
+ public void subscribeFailed(Topic topic) {
+ logger.log("Subcribe failed :" + topic);
+ }
+
+}
+
+/**
+ * Waits for a Resource to be delivered
+ *
+ * @author markush
+ *
+ * @version $Revision: 1.11 $
+ */
+class DataPastContentContinuation implements Continuation {
+ static final DataPastContent EMPTY_DATA_PAST_CONTENT = new EmptyResource();
+
+ private DataPastContent data;
+
+ private Exception exception;
+
+ public DataPastContentContinuation() {
+ this.data = EMPTY_DATA_PAST_CONTENT;
+ }
+
+ /**
+ * Method getData.
+ *
+ * @return DataPastContent
+ * @throws Exception
+ */
+ public DataPastContent getData() throws Exception {
+ if (exception != null) {
+ throw exception;
+ }
+ return data;
+ }
+
+ /**
+ * Method receiveException.
+ *
+ * @param result
+ * Exception
+ * @see rice.Continuation#receiveException(Exception)
+ */
+ public void receiveException(Exception result) {
+ exception = result;
+ }
+
+ /**
+ * Method receiveResult.
+ *
+ * @param result
+ * Object
+ * @see rice.Continuation#receiveResult(Object)
+ */
+ public void receiveResult(Object result) {
+ if (result instanceof DataPastContent || result == null) {
+ data = (DataPastContent) result;
+ }
+
+ }
+
+}
+
+/**
+ * Dummy Resource, used in the busy wait loop
+ *
+ * @author markush
+ *
+ * @version $Revision: 1.11 $
+ */
+class EmptyResource extends DataPastContent {
+
+ public EmptyResource() {
+ super(null, null);
+ }
+
+}
+
+/**
+ */
+class DataSignResponse implements ScribeContent {
+
+ private String identifier;
+
+ private byte[] signature;
+
+ private SignablePublicKey signer;
+
+ /**
+ * Constructor for DataSignResponse.
+ *
+ * @param identifier
+ * String
+ * @param signature
+ * byte[]
+ * @param signer
+ * Id
+ */
+ public DataSignResponse(String identifier, byte[] signature,
+ SignablePublicKey signer) {
+ super();
+ this.identifier = identifier;
+ this.signature = signature;
+ this.signer = signer;
+ }
+
+ /**
+ * Method getIdentifier.
+ *
+ * @return String
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * Method getSignature.
+ *
+ * @return byte[]
+ */
+ public byte[] getSignature() {
+ return signature;
+ }
+
+ /**
+ * Method getSigner.
+ *
+ * @return Id
+ */
+ public SignablePublicKey getSigner() {
+ return signer;
+ }
+
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/data/StringData.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/data/StringData.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/data/StringData.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,65 @@
+package de.upb.mmog.net.data;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * A Data-class that can store Strings
+ */
+public class StringData extends AbstractData {
+
+ private String data;
+
+ /**
+ * Constructor for StringData.
+ * @param identifier String
+ * @param data String
+ */
+ public StringData(String identifier, String data) {
+ super(identifier);
+ this.data = data;
+ }
+
+ /**
+ * the String as a byte aray
+ * @return byte[]
+ * @see de.upb.mmog.net.security.Signed#getData()
+ */
+ @Override
+ public byte[] getData() {
+ try {
+ return data.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Method getVersion.
+ * @return int
+ * @see org.p2play.data.Data#getVersion()
+ */
+ @Override
+ public int getVersion() {
+ return 0;
+ }
+
+ /**
+ * Method getStringData.
+ * @return String
+ */
+ public String getStringData() {
+ return data;
+ }
+
+ /**
+ * Method toString.
+ * @return String
+ */
+ @Override
+ public String toString() {
+ return "StringData: " + getIdentifier() + " : " + data;
+ }
+
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/region/impl/DummyClient.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/region/impl/DummyClient.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/region/impl/DummyClient.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,21 @@
+package de.upb.mmog.net.region.impl;
+
+import org.p2play.region.Client;
+import org.p2play.region.GameState;
+import org.p2play.region.Region;
+
+public class DummyClient implements Client {
+
+ public static final DummyClient DUMMY_CLIENT=new DummyClient();
+
+ public void handleGameStateChanged(Region region, GameState gameState) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void handleRegionChange(Region oldRegion, Region newRegion, Object gameObject) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/region/impl/GameRegion.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/region/impl/GameRegion.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/region/impl/GameRegion.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,38 @@
+package de.upb.mmog.net.region.impl;
+
+import org.p2play.region.Region;
+
+/**
+ * Simple Region, where the game name is the region name
+ * @author markus
+ *
+ */
+public class GameRegion implements Region {
+
+ private String game;
+
+ public GameRegion(String game) {
+ super();
+ this.game = game;
+ }
+
+ public String getGame() {
+ return game;
+ }
+
+ public String getRegionIdentifier() {
+ // TODO Auto-generated method stub
+ return game;
+ }
+
+ @Override
+ public int hashCode() {
+ return getRegionIdentifier().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj.equals(getRegionIdentifier());
+ }
+
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/region/impl/GroupedDynamicRegionManager.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/region/impl/GroupedDynamicRegionManager.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/region/impl/GroupedDynamicRegionManager.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,242 @@
+package de.upb.mmog.net.region.impl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.p2play.io.Serializer;
+import org.p2play.region.Client;
+import org.p2play.region.GameAction;
+import org.p2play.region.GameState;
+import org.p2play.region.Region;
+import org.p2play.region.RegionInstance;
+import org.p2play.region.RegionManager;
+import org.p2play.region.ServerFactory;
+import org.p2play.region.impl.NetworkHandler;
+import org.p2play.region.impl.ServerHandler;
+import org.p2play.region.impl.TimeManager;
+import org.p2play.region.message.GameActionMessage;
+import org.p2play.region.message.GameStateMessage;
+import org.p2play.region.message.JoinMessage;
+import org.p2play.region.message.RegionMessage;
+import org.p2play.scripting.pnuts.api.region.RegionChangeGameAction;
+import org.p2play.util.ListMap;
+
+import rice.p2p.commonapi.Node;
+import rice.p2p.past.Past;
+import rice.p2p.past.PastImpl;
+import rice.p2p.scribe.Scribe;
+import rice.p2p.scribe.ScribeImpl;
+import rice.persistence.LRUCache;
+import rice.persistence.MemoryStorage;
+import rice.persistence.StorageManagerImpl;
+import de.upb.mmog.net.data.PastDataManager;
+
+public class GroupedDynamicRegionManager implements RegionManager, Runnable {
+ private ListMap<Region, Client> clientMap;
+
+ private HashMap<Region, GameState> gameStateMap;
+
+ private List<GameAction> clientInteractionQueue;
+
+ private NetworkHandler networkHandler;
+
+ private static int tickGap = 100;
+
+ private TimeManager timeManager;
+
+ private ServerHandler serverHandler;
+
+ private int instances;
+ // The names of the instances of the regions where this is the controller
+ // of.
+ private ListMap<Region, RegionInstance> regionInstances; // <regionName,
+
+ public GroupedDynamicRegionManager(Serializer serializer, Node node,
+ ServerFactory serverFactory) {
+
+ instances=3;
+
+ regionInstances=new ListMap<Region, RegionInstance>();
+
+ timeManager = TimeManager.create(node);
+
+ clientMap = new ListMap<Region, Client>();
+ gameStateMap = new HashMap<Region, GameState>();
+
+ clientInteractionQueue = new LinkedList<GameAction>();
+
+ networkHandler = new NetworkHandler(serializer, this, node);
+
+ Past past = new PastImpl(node, new StorageManagerImpl(node
+ .getIdFactory(), new MemoryStorage(node.getIdFactory()),
+ new LRUCache(new MemoryStorage(node.getIdFactory()),
+ 1000 * 1000, node.getEnvironment())), 3, "gamestate");
+ Scribe scribe = new ScribeImpl(node, "gamestate");
+ serverHandler = new ServerHandler(this, new PastDataManager(node
+ .getId(), past, scribe), serverFactory);
+
+ new Thread(this).start();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.upb.mmog.net.region.RegionManager#joinRegion(java.lang.String,
+ * de.upb.mmog.net.region.Client)
+ */
+ public void joinRegion(Region region, Client client) {
+ if (client != serverHandler)
+ System.out.println(client + " joins " + region);
+ synchronized (clientMap) {
+ clientMap.add(region, client);
+ networkHandler.joinRegion(region, timeManager.getGameTime(),instances);
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.upb.mmog.net.region.RegionManager#leaveRegion(java.lang.String,
+ * de.upb.mmog.net.region.Client)
+ */
+ public void leaveRegion(Region region, Client client) {
+ if (client != serverHandler)
+ System.out.println(client + " leaves " + region);
+ synchronized (clientMap) {
+ clientMap.remove(region, client);
+
+ if (clientMap.isEmpty(region)) {
+ // leave the region, if no server process is running on us
+ if (!serverHandler.hasServer(region)) {
+ networkHandler.leaveRegion(region);
+ }
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.upb.mmog.net.region.RegionManager#scheduleInteraction(de.upb.mmog.net.region.Client,
+ * de.upb.mmog.net.region.Interaction)
+ */
+ public void scheduleInteraction(Client client, GameAction interaction) {
+ synchronized (clientInteractionQueue) {
+ clientInteractionQueue.add(interaction);
+ }
+ }
+
+ /**
+ * 1. execute server processes 2. update client processes with new game
+ * state 3. send game state change requests
+ */
+ @SuppressWarnings("unchecked")
+ public void run() {
+ while (true) {
+ long time = System.currentTimeMillis();
+ Iterator<Region> servers = serverHandler.iteratorOfRegions();
+ while (servers.hasNext()) {
+ Region server = servers.next();
+
+ serverHandler.tick(server);
+
+ Iterator<RegionInstance> iterator=regionInstances.iterator(server);
+ while (iterator.hasNext()) {
+ RegionInstance instance = iterator.next();
+ GameState gameState = serverHandler.getGameState(server);
+ if(gameState.getGameTime()%instances==instance.getInstance()) {
+ networkHandler.sendGameState(gameState,instance);
+ }else{
+ networkHandler.sendGameStateHash(gameState, instance);
+ }
+ }
+
+ }
+ // TODO: clear old requests
+
+ // Iterate over the regions
+ synchronized (clientMap) {
+ Iterator<Region> regions = clientMap.keySet().iterator();
+
+ while (regions.hasNext()) {
+ Region region = regions.next();
+
+ GameState gameState = gameStateMap.get(region);// remove(region);
+
+ // Iterate over the controllers
+ Iterator<Client> clients = clientMap.iterator(region);
+ while (clients.hasNext()) {
+ Client client = clients.next();
+ // update the client with the current game state
+ if (region != null && gameState != null) {
+ client.handleGameStateChanged(region, gameState);
+ }
+ }
+ }
+
+ }
+
+ synchronized (clientInteractionQueue) {
+ Iterator<GameAction> requests = clientInteractionQueue
+ .iterator();
+ while (requests.hasNext()) {
+ GameAction request = requests.next();
+
+ networkHandler.sendInteraction(request);
+ requests.remove();
+ }
+ }
+
+ try {
+ Thread.sleep(Math.max(1, tickGap + time
+ - System.currentTimeMillis()));
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public void handleMessageReceived(RegionMessage message) {
+ if (message instanceof GameActionMessage) {
+ GameActionMessage im = (GameActionMessage) message;
+
+ // TODO gefuckelt
+ synchronized (clientMap) {
+ if (im.getGameAction() instanceof RegionChangeGameAction) {
+ RegionChangeGameAction rcga = (RegionChangeGameAction) im
+ .getGameAction();
+ System.out.println("!!!Got Regionchange: "
+ + rcga.getSourceRegion() + "->" + rcga.getRegion());
+ System.out.println(clientMap);
+ if (!rcga.getSourceRegion().equals(rcga.getRegion())) {
+ Iterator<Client> iterator = clientMap.iterator(rcga
+ .getSourceRegion());
+ while (iterator.hasNext()) {
+ Client client = iterator.next();
+
+ client.handleRegionChange(rcga.getSourceRegion(), rcga.getRegion(), rcga
+ .getGameObject());
+ }
+ }
+ }
+ }
+
+ serverHandler.addGameAction(im.getRegion(), im.getGameAction());
+ } else if (message instanceof GameStateMessage) {
+ GameStateMessage gsm = (GameStateMessage) message;
+
+ gameStateMap.put(gsm.getRegion(), gsm.getGameState());
+ } else if (message instanceof JoinMessage) {
+ JoinMessage jm = (JoinMessage) message;
+
+ regionInstances.add(jm.getRegion(), jm.getRegionInstance());
+
+ serverHandler.startServer(jm.getRegion(), jm.getGameTime());
+ }// TODO: add handling of leave message
+ }
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/region/impl/GroupedStaticNetworkRegionManager.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/region/impl/GroupedStaticNetworkRegionManager.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/region/impl/GroupedStaticNetworkRegionManager.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,477 @@
+package de.upb.mmog.net.region.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.p2play.io.Serializer;
+import org.p2play.region.Client;
+import org.p2play.region.GameAction;
+import org.p2play.region.GameState;
+import org.p2play.region.Region;
+import org.p2play.region.RegionInstance;
+import org.p2play.region.RegionManager;
+import org.p2play.region.Server;
+import org.p2play.region.ServerFactory;
+import org.p2play.region.impl.NetworkHandler;
+import org.p2play.region.impl.TimeManager;
+import org.p2play.region.message.GameActionMessage;
+import org.p2play.region.message.GameStateHashMessage;
+import org.p2play.region.message.GameStateMessage;
+import org.p2play.region.message.JoinMessage;
+import org.p2play.region.message.RegionMessage;
+import org.p2play.util.EmptyIterator;
+import org.p2play.util.ListMap;
+
+import rice.environment.logging.Logger;
+import rice.p2p.commonapi.Node;
+
+public final class GroupedStaticNetworkRegionManager implements Runnable,
+ RegionManager {
+ private Logger logger;
+
+ private ListMap<Region, GameState> receivedGameStates;
+
+ //All received game state hashes, key=region
+ private ListMap<Region, GameStateHashMessage> receivedGameStateHashes;
+
+ // The names of the instances of the regions where this is the controller
+ // of.
+ private ListMap<Region, RegionInstance> regionInstances; // <regionName,
+
+ // InstanceName>
+
+ // The Names of the Instances which send the last gameStates
+ private HashMap<Region, RegionInstance> lastSendingInstances; // <regionName,
+
+ // InstanceName>
+
+ private HashMap<RegionInstance, Long> lastGameStateTimes;
+
+ // all clients in the specified region
+ private HashMap<Region, List<Client>> clientMap;
+
+ private HashMap<Region, Server> serverMap;
+
+ // Gamestate for each region for the clients only
+ private HashMap<Region, GameState> clientGameStateMap;
+
+ // Gamestate for each region for the regionController
+ private HashMap<Region, GameState> regionControllerGameStateMap;
+
+ // Interaction Queue which is inserted in the Gamestate in each tick
+ private List<GameAction> clientInteractionQueue;
+
+ // all saved gamesActions for each region
+ private HashMap<Region, List<GameAction>> serverInteractionMap;
+
+ private NetworkHandler networkHandler;
+
+ private ServerFactory serverFactory;
+
+ // time between two ticks in ms
+ private static int tickGap = 100;
+
+ // save last ticktime for each region
+ // necessary too detect a failure of the regionController
+ private HashMap<Region, Long> lastTickTime;
+
+ private TimeManager timeManager;
+
+ private int instances;
+
+ public GroupedStaticNetworkRegionManager(Serializer serializer, Node node,
+ ServerFactory serverFactory, int instances) {
+ this.logger = node.getEnvironment().getLogManager().getLogger(
+ this.getClass(), "");
+
+ this.serverFactory = serverFactory;
+ this.instances = instances;
+
+ receivedGameStates = new ListMap<Region, GameState>();
+ receivedGameStateHashes= new ListMap<Region, GameStateHashMessage>();
+ regionInstances = new ListMap<Region, RegionInstance>();
+ lastSendingInstances = new HashMap<Region, RegionInstance>();
+ lastGameStateTimes = new HashMap<RegionInstance, Long>();
+ clientMap = new HashMap<Region, List<Client>>();
+ serverMap = new HashMap<Region, Server>();
+ lastTickTime = new HashMap<Region, Long>();
+
+ clientGameStateMap = new HashMap<Region, GameState>();
+ regionControllerGameStateMap = new HashMap<Region, GameState>();
+
+ clientInteractionQueue = new LinkedList<GameAction>();
+ serverInteractionMap = new HashMap<Region, List<GameAction>>();
+
+ networkHandler = new NetworkHandler(serializer, this, node);
+
+ timeManager = TimeManager.create(node);
+
+ new Thread(this).start();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.upb.mmog.net.region.RegionManager#joinRegion(java.lang.String,
+ * de.upb.mmog.net.region.Client)
+ */
+ public void joinRegion(Region region, Client client) {
+ synchronized (clientMap) {
+ List<Client> list = clientMap.get(region);
+
+ if (list == null) {
+ list = new LinkedList<Client>();
+ clientMap.put(region, list);
+ }
+
+ if (!list.contains(client)) {
+ list.add(client);
+ }
+
+ networkHandler.joinRegion(region, timeManager.getGameTime(),
+ instances);
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.upb.mmog.net.region.RegionManager#leaveRegion(java.lang.String,
+ * de.upb.mmog.net.region.Client)
+ */
+ public void leaveRegion(Region region, Client client) {
+ synchronized (clientMap) {
+ List<Client> list = clientMap.get(region);
+
+ if (list != null) {
+ if (list.contains(client)) {
+ list.remove(client);
+ }
+
+ if (list.isEmpty()) {
+ // last one, remove the list
+ clientMap.remove(region);
+
+ // and leave the region, if no server process is running on
+ // us
+ if (!serverMap.containsKey(region)) {
+ networkHandler.leaveRegion(region);
+ }
+ }
+ }
+ }
+
+ }
+
+ /*
+ * //Client ruft dies auf wenn er was machen will
+ *
+ * @see de.upb.mmog.net.region.RegionManager#scheduleInteraction(de.upb.mmog.net.region.Client,
+ * de.upb.mmog.net.region.Interaction)
+ */
+ public void scheduleInteraction(Client client, GameAction interaction) {
+ synchronized (clientInteractionQueue) {
+ clientInteractionQueue.add(interaction);
+ }
+ }
+
+ /**
+ * 1. execute server processes 2. update client processes with new game
+ * state 3. send game state change requests
+ */
+ @SuppressWarnings("unchecked")
+ public void run() {
+ while (true) {
+ long time = System.currentTimeMillis();
+
+ long gameTime = timeManager.getGameTime();
+
+ //System.out.println("Ticking game time: " + gameTime);
+ //System.out.println(lastGameStateTimes);
+
+ // check all gamestates we received and pick the one that has the
+ // most same hashes
+ Iterator<Region> regions = receivedGameStates.clonedIterator();
+ while (regions.hasNext()) {
+ Region region = regions.next();
+
+ //System.out.println("region: " + region);
+
+ // find the gamestate of the region that has the most correct
+ // hashes
+ HashMap<String, Integer> counter = new HashMap<String, Integer>();
+
+ synchronized(receivedGameStates){
+ Iterator<GameState> gamestates = receivedGameStates
+ .iterator(region);
+
+ //System.out.println(receivedGameStates);
+
+ int max = 0;
+ GameState bestState = null;
+
+ while (gamestates.hasNext()) {
+ GameState gameState = gamestates.next();
+
+ /*if (gameState.getGameTime() <= gameTime - 1) {
+ continue;
+ }*/
+
+ String hash = String.valueOf(gameState.hash());
+
+ if (!counter.containsKey(hash)) {
+ counter.put(hash, 1);
+ } else {
+ counter.put(hash, counter.get(hash) + 1);
+ }
+
+ int nmax = Math.max(max, counter.get(hash));
+
+ if (nmax > max) {
+ bestState = gameState;
+ }
+
+ max = nmax;
+ }
+
+ //System.out.println(counter);
+ //System.out.println("GameState: " + bestState + " has most: " + max);
+
+ if (bestState != null) {
+ clientGameStateMap.put(bestState.getRegion(), bestState);
+ regionControllerGameStateMap.put(bestState.getRegion(),
+ bestState);
+ }else {
+ logger.log("No Gamestate for tick "+gameTime+" for region "+region);
+ }
+
+ receivedGameStates.remove(region);
+ }
+ }
+
+ // first test which regioncontrollers are still running and restart
+ // the others
+ HashSet<Region> set = new HashSet<Region>();
+ set.addAll(serverMap.keySet());
+ set.addAll(clientMap.keySet());
+
+ // Iterator<String> regions = set.iterator();
+ /*
+ * while (regions.hasNext()) { String region = regions.next();
+ *
+ * for (int i = 0; i < instances; i++) { String instance =
+ * networkHandler.getInstanceName(region, i); if
+ * (lastGameStateTimes.get(instance) != null && (gameTime -
+ * lastGameStateTimes.get(instance) > 50)) { // got a message too
+ * long ago (5 ticks) // rejoin networkHandler.joinRegion(region,
+ * instance, gameTime); logger.log("Rejoining instance: " +
+ * instance); } }
+ * }
+ */
+
+ Iterator<Server> servers = ((HashMap<String, Server>) serverMap
+ .clone()).values().iterator();
+ while (servers.hasNext()) {
+ Server server = servers.next();
+
+ List<GameAction> requests = serverInteractionMap.remove(server
+ .getRegion());
+
+ GameState gameState = regionControllerGameStateMap.get(server
+ .getRegion());
+ if (gameState != null) {
+ while (gameState.getGameTime() < gameTime) {
+ gameState = server.tick(gameState, requests);
+ }
+ regionControllerGameStateMap.put(server.getRegion(),
+ gameState);
+ synchronized(regionInstances){
+ Iterator<RegionInstance> instances = regionInstances
+ .iterator(server.getRegion());
+ while (instances.hasNext()) {
+ RegionInstance instance = instances.next();
+ if (networkHandler.isRoot(instance)) {
+ if((gameTime+instance.getInstance())%this.instances==0)
+ {
+ //System.out.println("Sending GameState!");
+ networkHandler.sendGameState(gameState, instance);
+ }
+ else{
+ //send the hash of the gameState
+ //System.out.println("Sending Hash!");
+ networkHandler.sendGameStateHash(gameState, instance);
+ }
+ } else {
+ logger
+ .log("I'm no longer controller for instance: "
+ + instance);
+ regionInstances
+ .remove(server.getRegion(), instance);
+ networkHandler.joinRegion(instance, gameTime);
+ }
+
+ }
+ }
+ // TODO: close server if all instances are closed
+ // TODO: send diffs
+ // scribeThread.sendGameStateDiff(diff);
+ }
+ }
+ // TODO: clear old requests
+
+ // Iterate over the regions
+ synchronized (clientMap) {
+
+ regions = clientMap.keySet().iterator();
+
+ while (regions.hasNext()) {
+ Region region = regions.next();
+
+ GameState gameState = clientGameStateMap.get(region);// remove(region);
+
+ // Iterate over the controllers
+ Iterator<Client> clients = iteratorOfClients(region);
+ while (clients.hasNext()) {
+ Client client = clients.next();
+
+ // update the client with the current game state
+ if (region != null && gameState != null) {
+ client.handleGameStateChanged(region, gameState);
+ }
+ }
+
+ }
+ }
+
+ // schicke alle gesammelten Client-Kommandos los
+ synchronized (clientInteractionQueue) {
+ Iterator<GameAction> requests = clientInteractionQueue
+ .iterator();
+ while (requests.hasNext()) {
+ GameAction request = requests.next();
+ // logger.log("Sending interaction, region:
+ // "+request.getRegion()+", Instance: "+
+ // regionInstances.get(request.getRegion()));
+ // locate instance which send the last gamestate and send a
+ // interaction-request to
+ // String actuRegionInstance =
+ // regionInstances.get(request.getRegion());
+ networkHandler.sendInteraction(request);
+ requests.remove();
+ }
+ }
+
+ try {
+ Thread.sleep(Math.max(1, tickGap + time
+ - System.currentTimeMillis()));
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ private Iterator<Client> iteratorOfClients(Region region) {
+ if (clientMap.containsKey(region)) {
+ return clientMap.get(region).iterator();
+ } else {
+ return new EmptyIterator<Client>();
+ }
+ }
+
+ public void handleMessageReceived(RegionMessage message) {
+ if (message instanceof GameActionMessage) {
+ GameActionMessage im = (GameActionMessage) message;
+
+ synchronized (serverInteractionMap) {
+
+ List<GameAction> list = serverInteractionMap
+ .get(im.getRegionInstance().getRegion());
+
+ if (list == null) {
+ list = new LinkedList<GameAction>();
+ serverInteractionMap.put(im.getRegionInstance().getRegion(), list);
+ }
+
+ list.add(im.getGameAction());
+
+ }
+ } else if (message instanceof GameStateMessage) {
+
+ // set the "lastSendingInstances"
+ lastSendingInstances.put(message.getRegionInstance().getRegion(), message
+ .getRegionInstance());
+
+ lastTickTime.put(message.getRegionInstance().getRegion(), System.currentTimeMillis());
+ GameStateMessage gsm = (GameStateMessage) message;
+
+ lastGameStateTimes.put(message.getRegionInstance(), gsm
+ .getGameState().getGameTime());
+
+ receivedGameStates.add(message.getRegionInstance().getRegion(), gsm.getGameState());
+ } else if (message instanceof JoinMessage) {
+ JoinMessage jm = (JoinMessage) message;
+ // start the server if needed
+ Server server = serverMap.get(jm.getRegionInstance().getRegion());
+ regionInstances.add(jm.getRegionInstance().getRegion(), jm.getRegionInstance());
+ if (server == null) {
+
+ server = serverFactory.getServer(jm.getRegionInstance().getRegion());
+ // timeWhereItBecameController=System.currentTimeMillis();
+
+ logger.log("Created controller instance \""
+ + jm.getRegionInstance() + "\" for region : "
+ + jm.getRegionInstance().getRegion());
+
+ long randomSeed = 0;
+ try {
+ randomSeed = new DataInputStream(new ByteArrayInputStream(
+ networkHandler.getTopic(new RegionInstance(jm.getRegionInstance().getRegion(),0)).getId()
+ .toByteArray())).readLong();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ GameState gameState = server.init(jm.getGameTime(), randomSeed);
+ regionControllerGameStateMap.put(jm.getRegionInstance().getRegion(), gameState);
+ synchronized (serverMap) {
+ serverMap.put(jm.getRegionInstance().getRegion(), server);
+ }
+
+ networkHandler.joinRegion(jm.getRegionInstance().getRegion(), jm.getGameTime());
+
+ //TODO: auch gefrickelt...
+ //join all neigbours
+ Iterator<Region> neighbouts = server.getNeighbourRegionIdentifiers().iterator();
+ while(neighbouts.hasNext()){
+ Region region=neighbouts.next();
+ joinRegion(region, DummyClient.DUMMY_CLIENT);
+ }
+
+ }// TODO: add handling of leave message
+
+ // send the current game state to the client
+ // scribeThread.sendGameState(jm.getSender(),
+ // gameStateMap.get(jm.getRegion()));
+ }
+ else if(message instanceof GameStateHashMessage) {
+
+ GameStateHashMessage gshm=(GameStateHashMessage)message;
+
+ //System.out.println("Region hash: "+gshm.getRegion());
+ receivedGameStateHashes.add(gshm.getRegion(),gshm);
+
+ //System.out.println("Received GameStatHash!");
+
+ // TODO test the hash with the actual gameState
+ //System.out.println("GameState Hash: "+gshm.getHash());
+ }
+ }
+}
\ No newline at end of file
Added: P2PlayLegacy/src/de/upb/mmog/net/region/impl/ObjectGameAction.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/region/impl/ObjectGameAction.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/region/impl/ObjectGameAction.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,40 @@
+package de.upb.mmog.net.region.impl;
+
+import org.p2play.region.GameAction;
+import org.p2play.region.Region;
+
+
+public class ObjectGameAction implements GameAction {
+
+ private Region region;
+ private long gameTime;
+ private Object object;
+
+ public ObjectGameAction(Region region,long gameTime, Object object) {
+ super();
+ this.region = region;
+ this.gameTime = gameTime;
+ this.object = object;
+ }
+
+ public long getGameTime() {
+ return gameTime;
+ }
+
+
+
+ public Object getObject() {
+ return object;
+ }
+
+
+
+ public Region getRegion() {
+ return region;
+ }
+
+ public boolean sendToAll() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/region/impl/PeerToPeerRegionManager.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/region/impl/PeerToPeerRegionManager.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/region/impl/PeerToPeerRegionManager.java 2007-03-20 12:17:08 UTC (rev 50)
@@ -0,0 +1,229 @@
+package de.upb.mmog.net.region.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.p2play.io.Serializer;
+import org.p2play.region.Client;
+import org.p2play.region.GameAction;
+import org.p2play.region.GameState;
+import org.p2play.region.Region;
+import org.p2play.region.RegionInstance;
+import org.p2play.region.RegionManager;
+import org.p2play.region.Server;
+import org.p2play.region.ServerFactory;
+import org.p2play.region.impl.NetworkHandler;
+import org.p2play.region.impl.TimeManager;
+import org.p2play.region.message.GameActionMessage;
+import org.p2play.region.message.GameStateMessage;
+import org.p2play.region.message.JoinMessage;
+import org.p2play.region.message.RegionMessage;
+import org.p2play.util.ListMap;
+
+import rice.environment.logging.Logger;
+import rice.p2p.commonapi.Node;
+
+public class PeerToPeerRegionManager implements RegionManager, Runnable {
+ private NetworkHandler networkHandler;
+
+ private Logger logger;
+
+ private ServerFactory serverFactory;
+
+ private ListMap<Region, Client> clientMap;
+
+ private HashMap<Region, Server> serverMap;
+
+ private ListMap<Region, GameAction> serverActionMap;
+
+ private HashMap<Region, GameState> gameStateMap;
+
+ private List<GameAction> clientActionQueue;
+
+ private static int tickGap = 100;
+
+ private TimeManager timeManager;
+
+ public PeerToPeerRegionManager(Serializer serializer, Node node, ServerFactory serverFactory) {
+ this.logger = node.getEnvironment().getLogManager().getLogger(
+ this.getClass(), "");
+ this.serverFactory = serverFactory;
+ networkHandler = new NetworkHandler(serializer, this, node);
+
+ this.clientMap = new ListMap<Region, Client>();
+ this.serverMap = new HashMap<Region, Server>();
+ this.serverActionMap = new ListMap<Region, GameAction>();
+ this.gameStateMap = new HashMap<Region, GameState>();
+ this.clientActionQueue = new LinkedList<GameAction>();
+ this.timeManager=TimeManager.create(node);
+
+ new Thread(this).start();
+ }
+
+ public void joinRegion(Region region, Client client) {
+ startServer(region,timeManager.getGameTime());
+ networkHandler.joinRegion(region,timeManager.getGameTime());
+ clientMap.add(region, client);
+ }
+
+ public void leaveRegion(Region region, Client client) {
+ networkHandler.leaveRegion(region);
+ clientMap.remove(region, client);
+ }
+
+ public void scheduleInteraction(Client client, GameAction interaction) {
+ clientActionQueue.add(interaction);
+ }
+
+ public void handleMessageReceived(RegionMessage message) {
+ if (message instanceof GameActionMessage) {
+ GameActionMessage im = (GameActionMessage) message;
+ serverActionMap.add(im.getRegion(), im.getGameAction());
+ } else if (message instanceof GameStateMessage) {
+ GameStateMessage gsm = (GameStateMessage) message;
+
+ gameStateMap.put(gsm.getRegion(), gsm.getGameState());
+ } else if (message instanceof JoinMessage) {
+ JoinMessage jm = (JoinMessage) message;
+
+ Server server = startServer(jm.getRegion(),jm.getGameTime());
+
+ // send the current game state to the client
+ networkHandler.sendGameState(jm.getSender(), gameStateMap
+ .get(server.getRegion()));
+ }
+ // TODO: add handling of leave message
+ }
+
+ private Server startServer(Region region, long gameTime) {
+ // start the server if needed
+ Server server = serverMap.get(region);
+ if (server == null) {
+ server = serverFactory.getServer(region);
+
+ long randomSeed=0;
+ try {
+ randomSeed = new DataInputStream(new ByteArrayInputStream(networkHandler.getTopic(new RegionInstance(region,0)).getId().toByteArray())).readLong();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ GameState gameState = server.init(randomSeed, gameTime);
+ gameStateMap.put(region, gameState);
+
+ // TODO: tick to current time
+ synchronized (serverMap) {
+ serverMap.put(region, server);
+ }
+
+ networkHandler.joinRegion(region,gameTime);
+
+ //TODO: auch gefrickelt...
+ //join all neigbours
+ /*Iterator<Region> neighbouts = server.getNeighbourRegionIdentifiers().iterator();
+ while(neighbouts.hasNext()){
+ Region region=neighbouts.next();
+ joinRegion(region, dummyClient);
+ }*/
+
+
+ logger.log("Created controller for: " + region);
+ }
+ return server;
+ }
+
+ /**
+ * 1. execute server processes 2. update client processes with new game
+ * state 3. send game state change requests
+ */
+ @SuppressWarnings("unchecked")
+ public void run() {
+ while (true) {
+ long time = System.currentTimeMillis();
+ Iterator<Server> servers = ((HashMap<String, Server>)serverMap.clone()).values().iterator();
+ while (servers.hasNext()) {
+ Server server = servers.next();
+
+ GameState gameState = gameStateMap.get(server.getRegion());
+
+ if (gameState != null) {
+
+ Iterator<GameAction> requests = serverActionMap
+ .iterator(server.getRegion());
+
+ List<GameAction> currentActionList = new LinkedList<GameAction>();
+
+ while (requests.hasNext()) {
+ GameAction action = requests.next();
+
+ /*if (action.getGameTime() < gameState.getGameTime()) {
+ // remove old
+ requests.remove();
+ } else if (action.getGameTime() == gameState
+ .getGameTime()) {*/
+ // handle current
+ currentActionList.add(action);
+ requests.remove();
+ /*} else {
+ // leave too new
+ }*/
+ }
+
+ gameState=server.tick(gameState, currentActionList);
+ gameStateMap.put(server.getRegion(), gameState);
+ //logger.log("Hash of gamestate " +gameState.getRegion()+" "+ gameState.getGameTime() + " "
+ // + gameState.hash());
+ }
+
+ }
+ // TODO: clear old requests
+
+ // Iterate over the regions
+ Iterator<Region> regions = clientMap.keySet().iterator();
+
+ while (regions.hasNext()) {
+ Region region = regions.next();
+
+ GameState gameState = gameStateMap.get(region);//remove(region);
+
+ // Iterate over the controllers
+ Iterator<Client> clients = clientMap.iterator(region);
+ while (clients.hasNext()) {
+ Client client = clients.next();
+
+ // update the client with the current game state
+ if (region != null && gameState != null) {
+ client.handleGameStateChanged(region, gameState);
+ }
+ }
+
+ }
+
+ synchronized (clientActionQueue) {
+ Iterator<GameAction> requests = clientActionQueue.iterator();
+ while (requests.hasNext()) {
+ GameAction request = requests.next();
+ GameState state = gameStateMap.get(request.getRegion());
+ if (state != null) {
+ networkHandler.sendExtendedInteraction(request, state
+ .getGameTime(), state.hash());
+ requests.remove();
+ }
+ }
+ }
+
+ try {
+ Thread.sleep(Math.max(1, tickGap + time
+ - System.currentTimeMillis()));
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+}
Added: P2PlayLegacy/src/de/upb/mmog/net/resource/PastResourceManager.java
===================================================================
--- P2PlayLegacy/src/de/upb/mmog/net/resource/PastResourceManager.java (rev 0)
+++ P2PlayLegacy/src/de/upb/mmog/net/resource/PastResourceManager.java 2007-03-20 12:17:08 UTC (rev 50)
@...
[truncated message content] |
|
From: <ti...@us...> - 2007-03-20 12:25:27
|
Revision: 46
http://p2play.svn.sourceforge.net/p2play/?rev=46&view=rev
Author: tisoft
Date: 2007-03-20 05:08:34 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
trunk/P2PlayAdmin/src/main/webapp/
trunk/P2PlayAdmin/src/main/webapp/index.html
Added: trunk/P2PlayAdmin/src/main/webapp/index.html
===================================================================
--- trunk/P2PlayAdmin/src/main/webapp/index.html (rev 0)
+++ trunk/P2PlayAdmin/src/main/webapp/index.html 2007-03-20 12:08:34 UTC (rev 46)
@@ -0,0 +1,10 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+<a href="org.p2play.web.vfs.VFS/VFS.html">VFS</a>
+</body>
+</html>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:07:03
|
Revision: 43
http://p2play.svn.sourceforge.net/p2play/?rev=43&view=rev
Author: tisoft
Date: 2007-03-20 04:55:27 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
P2PlayServiceServer/.classpath
P2PlayServiceServer/.project
P2PlayServiceServer/.settings/
P2PlayServiceServer/.settings/org.eclipse.jdt.core.prefs
P2PlayServiceServer/.settings/org.eclipse.wst.common.component
P2PlayServiceServer/.settings/org.eclipse.wst.common.project.facet.core.xml
P2PlayServiceServer/pom.xml
P2PlayServiceServer/src/
P2PlayServiceServer/src/main/
P2PlayServiceServer/src/main/java/
P2PlayServiceServer/src/main/java/org/
P2PlayServiceServer/src/main/java/org/p2play/
P2PlayServiceServer/src/main/java/org/p2play/service/
P2PlayServiceServer/src/main/java/org/p2play/service/server/
P2PlayServiceServer/src/main/java/org/p2play/service/server/AuthenticationServiceImpl.java
P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayServiceServer.java
P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayVfsServiceImpl.java
P2PlayServiceServer/src/main/java/org/p2play/service/server/node/
P2PlayServiceServer/src/main/java/org/p2play/service/server/node/StaticNode.java
Property Changed:
----------------
P2PlayServiceServer/
Property changes on: P2PlayServiceServer
___________________________________________________________________
Name: svn:ignore
+ target
Added: P2PlayServiceServer/.classpath
===================================================================
--- P2PlayServiceServer/.classpath (rev 0)
+++ P2PlayServiceServer/.classpath 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: P2PlayServiceServer/.project
===================================================================
--- P2PlayServiceServer/.project (rev 0)
+++ P2PlayServiceServer/.project 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>P2PlayServiceServer</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ </natures>
+</projectDescription>
Added: P2PlayServiceServer/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- P2PlayServiceServer/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ P2PlayServiceServer/.settings/org.eclipse.jdt.core.prefs 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,7 @@
+#Tue Mar 20 10:11:04 CET 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: P2PlayServiceServer/.settings/org.eclipse.wst.common.component
===================================================================
--- P2PlayServiceServer/.settings/org.eclipse.wst.common.component (rev 0)
+++ P2PlayServiceServer/.settings/org.eclipse.wst.common.component 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="P2PlayService">
+<wb-resource deploy-path="/" source-path="/src/main/java"/>
+</wb-module>
+</project-modules>
Added: P2PlayServiceServer/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
--- P2PlayServiceServer/.settings/org.eclipse.wst.common.project.facet.core.xml (rev 0)
+++ P2PlayServiceServer/.settings/org.eclipse.wst.common.project.facet.core.xml 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="jst.java"/>
+ <fixed facet="jst.utility"/>
+ <installed facet="jst.utility" version="1.0"/>
+ <installed facet="jst.java" version="5.0"/>
+</faceted-project>
Added: P2PlayServiceServer/pom.xml
===================================================================
--- P2PlayServiceServer/pom.xml (rev 0)
+++ P2PlayServiceServer/pom.xml 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayServiceServer</artifactId>
+ <version>0.0.1</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayBoot</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayService</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jetty</groupId>
+ <artifactId>org.mortbay.jetty</artifactId>
+ <version>5.1.6</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.3</version>
+ </dependency>
+ </dependencies>
+</project>
+
Added: P2PlayServiceServer/src/main/java/org/p2play/service/server/AuthenticationServiceImpl.java
===================================================================
--- P2PlayServiceServer/src/main/java/org/p2play/service/server/AuthenticationServiceImpl.java (rev 0)
+++ P2PlayServiceServer/src/main/java/org/p2play/service/server/AuthenticationServiceImpl.java 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.server;
+
+import javax.jws.WebService;
+
+import org.p2play.service.AuthenticationService;
+import org.p2play.service.exception.AuthenticationException;
+import org.p2play.service.object.AuthenticationToken;
+
+@WebService(serviceName = "AuthenticationService", endpointInterface = "org.p2play.service.AuthenticationService")
+public class AuthenticationServiceImpl implements AuthenticationService {
+
+ public AuthenticationToken login(String user, char[] password)
+ throws AuthenticationException {
+ if (password.length > 5)
+ return new AuthenticationToken() {
+ };
+ else
+ throw new AuthenticationException("Login incorrect");
+ }
+
+}
Added: P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayServiceServer.java
===================================================================
--- P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayServiceServer.java (rev 0)
+++ P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayServiceServer.java 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.server;
+
+import org.codehaus.xfire.XFire;
+import org.codehaus.xfire.XFireFactory;
+import org.codehaus.xfire.annotations.AnnotationServiceFactory;
+import org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations;
+import org.codehaus.xfire.server.http.XFireHttpServer;
+import org.p2play.service.server.node.StaticNode;
+
+public class P2PlayServiceServer {
+ public static void main(String[] args) throws Exception {
+ StaticNode.instance().init();
+
+ StaticNode.instance().getFileSystemManager();
+
+ XFire xfire = XFireFactory.newInstance().getXFire();
+ AnnotationServiceFactory factory = new AnnotationServiceFactory(
+ new Jsr181WebAnnotations(), xfire.getTransportManager());
+
+ xfire.getServiceRegistry().register(
+ factory.create(AuthenticationServiceImpl.class));
+ xfire.getServiceRegistry().register(
+ factory.create(P2PlayVfsServiceImpl.class));
+
+ new XFireHttpServer().start();
+ // http://localhost:8081/GreeterService?wsdl
+ }
+
+}
Added: P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayVfsServiceImpl.java
===================================================================
--- P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayVfsServiceImpl.java (rev 0)
+++ P2PlayServiceServer/src/main/java/org/p2play/service/server/P2PlayVfsServiceImpl.java 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.server;
+
+import javax.jws.WebService;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.p2play.service.P2PlayVfsService;
+import org.p2play.service.object.AuthenticationToken;
+import org.p2play.service.server.node.StaticNode;
+
+@WebService(serviceName = "P2PlayVfsService", endpointInterface = "org.p2play.service.P2PlayVfsService")
+public class P2PlayVfsServiceImpl implements P2PlayVfsService {
+ private static final String[] EMPTY_STRING = new String[0];
+
+ public void addFolder(AuthenticationToken token, String newFolder)
+ throws FileSystemException {
+ FileObject fileObject = StaticNode.instance().getFileSystemManager()
+ .resolveFile("p2play://" + newFolder);
+
+ fileObject.createFolder();
+ }
+
+ public void addFolder(AuthenticationToken token, String parent,
+ String newFolder) throws FileSystemException {
+ if (!parent.endsWith("/")) {
+ parent += "/";
+ }
+ addFolder(token, parent + newFolder);
+ }
+
+ public String[] getChildren(AuthenticationToken token, String parent)
+ throws FileSystemException {
+ FileObject fileObject = StaticNode.instance().getFileSystemManager()
+ .resolveFile("p2play://" + parent);
+
+ if (fileObject == null || !fileObject.getType().hasChildren())
+ return EMPTY_STRING;
+
+ FileObject[] children = fileObject.getChildren();
+ String[] childStrings = new String[children.length];
+
+ for (int i = 0; i < children.length; i++) {
+ childStrings[i] = children[i].getName().getBaseName();
+ }
+
+ return childStrings;
+ }
+}
Added: P2PlayServiceServer/src/main/java/org/p2play/service/server/node/StaticNode.java
===================================================================
--- P2PlayServiceServer/src/main/java/org/p2play/service/server/node/StaticNode.java (rev 0)
+++ P2PlayServiceServer/src/main/java/org/p2play/service/server/node/StaticNode.java 2007-03-20 11:55:27 UTC (rev 43)
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.server.node;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemManager;
+import org.apache.commons.vfs.impl.StandardFileSystemManager;
+import org.p2play.boot.pastry.NodeHandler;
+import org.p2play.boot.pastry.Pastry;
+import org.p2play.boot.vfs.PastryFileProvider;
+
+import rice.p2p.commonapi.Node;
+import rice.p2p.past.Past;
+import rice.p2p.past.PastImpl;
+import rice.p2p.scribe.Scribe;
+import rice.p2p.scribe.ScribeImpl;
+import rice.persistence.LRUCache;
+import rice.persistence.MemoryStorage;
+import rice.persistence.StorageManagerImpl;
+
+public class StaticNode implements NodeHandler {
+ private Node node;
+
+ private Map<String, Past> pastMap = new HashMap<String, Past>();
+
+ private Map<String, Scribe> scribeMap = new HashMap<String, Scribe>();
+
+ private FileSystemManager fileSystemManager;
+
+ private static StaticNode staticNode;
+
+ public Node getNode() {
+ if (node == null)
+ throw new RuntimeException("Node not initialized!");
+ return node;
+ }
+
+ public Past getPast(String instance) {
+ Past past = pastMap.get(instance);
+
+ if (past == null) {
+ past = new PastImpl(node, new StorageManagerImpl(node
+ .getIdFactory(), new MemoryStorage(node.getIdFactory()),
+ new LRUCache(new MemoryStorage(node.getIdFactory()), 100,
+ node.getEnvironment())), 3, instance);
+
+ pastMap.put(instance, past);
+ }
+
+ return past;
+ }
+
+ public Scribe getScribe(String instance) {
+ Scribe scribe = scribeMap.get(instance);
+
+ if (scribe == null) {
+ scribe = new ScribeImpl(getNode(), instance);
+
+ scribeMap.put(instance, scribe);
+ }
+
+ return scribe;
+ }
+
+ public FileSystemManager getFileSystemManager() {
+ if (fileSystemManager == null) {
+ fileSystemManager = new StandardFileSystemManager();
+ try {
+ ((StandardFileSystemManager) fileSystemManager).init();
+ ((StandardFileSystemManager) fileSystemManager).addProvider(
+ "p2play", new PastryFileProvider(this));
+
+ FileObject root = fileSystemManager.resolveFile("p2play:///");
+ FileObject testFolder = fileSystemManager
+ .resolveFile("p2play://test");
+ FileObject testFile = fileSystemManager
+ .resolveFile("p2play://test/file");
+ FileObject testClass = fileSystemManager
+ .resolveFile("p2play://Test.class");
+
+ DataOutputStream dos = new DataOutputStream(testFile
+ .getContent().getOutputStream());
+ dos.writeUTF("test content");
+ dos.close();
+
+ DataInputStream dis = new DataInputStream(testFile.getContent()
+ .getInputStream());
+ System.out.println(dis.readUTF());
+
+ testFolder.createFolder();
+
+ testClass.createFile();
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return fileSystemManager;
+ }
+
+ public void init() {
+ if (node == null) {
+ try {
+ node = Pastry.boot(new InetSocketAddress(InetAddress
+ .getLocalHost(), 10000), InetAddress.getLocalHost(),
+ 10000);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public static StaticNode instance() {
+ if (staticNode == null) {
+ staticNode = new StaticNode();
+ staticNode.init();
+ }
+
+ return staticNode;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:07:01
|
Revision: 42
http://p2play.svn.sourceforge.net/p2play/?rev=42&view=rev
Author: tisoft
Date: 2007-03-20 04:53:30 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
P2PlayService/.classpath
P2PlayService/.project
P2PlayService/.settings/
P2PlayService/.settings/org.eclipse.jdt.core.prefs
P2PlayService/.settings/org.eclipse.wst.common.component
P2PlayService/.settings/org.eclipse.wst.common.project.facet.core.xml
P2PlayService/pom.xml
P2PlayService/src/
P2PlayService/src/main/
P2PlayService/src/main/java/
P2PlayService/src/main/java/org/
P2PlayService/src/main/java/org/p2play/
P2PlayService/src/main/java/org/p2play/service/
P2PlayService/src/main/java/org/p2play/service/AuthenticationService.java
P2PlayService/src/main/java/org/p2play/service/P2PlayVfsService.java
P2PlayService/src/main/java/org/p2play/service/exception/
P2PlayService/src/main/java/org/p2play/service/exception/AuthenticationException.java
P2PlayService/src/main/java/org/p2play/service/object/
P2PlayService/src/main/java/org/p2play/service/object/AuthenticationToken.java
Property Changed:
----------------
P2PlayService/
Property changes on: P2PlayService
___________________________________________________________________
Name: svn:ignore
+ target
Added: P2PlayService/.classpath
===================================================================
--- P2PlayService/.classpath (rev 0)
+++ P2PlayService/.classpath 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: P2PlayService/.project
===================================================================
--- P2PlayService/.project (rev 0)
+++ P2PlayService/.project 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>P2PlayService</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ </natures>
+</projectDescription>
Added: P2PlayService/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- P2PlayService/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ P2PlayService/.settings/org.eclipse.jdt.core.prefs 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,7 @@
+#Tue Mar 20 10:11:04 CET 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: P2PlayService/.settings/org.eclipse.wst.common.component
===================================================================
--- P2PlayService/.settings/org.eclipse.wst.common.component (rev 0)
+++ P2PlayService/.settings/org.eclipse.wst.common.component 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="P2PlayService">
+<wb-resource deploy-path="/" source-path="/src/main/java"/>
+</wb-module>
+</project-modules>
Added: P2PlayService/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
--- P2PlayService/.settings/org.eclipse.wst.common.project.facet.core.xml (rev 0)
+++ P2PlayService/.settings/org.eclipse.wst.common.project.facet.core.xml 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="jst.java"/>
+ <fixed facet="jst.utility"/>
+ <installed facet="jst.utility" version="1.0"/>
+ <installed facet="jst.java" version="5.0"/>
+</faceted-project>
Added: P2PlayService/pom.xml
===================================================================
--- P2PlayService/pom.xml (rev 0)
+++ P2PlayService/pom.xml 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayService</artifactId>
+ <version>0.0.1</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.xfire</groupId>
+ <artifactId>xfire-java5</artifactId>
+ <version>1.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-vfs</groupId>
+ <artifactId>commons-vfs</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+</project>
+
Added: P2PlayService/src/main/java/org/p2play/service/AuthenticationService.java
===================================================================
--- P2PlayService/src/main/java/org/p2play/service/AuthenticationService.java (rev 0)
+++ P2PlayService/src/main/java/org/p2play/service/AuthenticationService.java 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+import org.p2play.service.exception.AuthenticationException;
+import org.p2play.service.object.AuthenticationToken;
+
+@WebService(serviceName = "AuthenticationService")
+public interface AuthenticationService {
+ @WebMethod
+ public AuthenticationToken login(String user, char[] password)
+ throws AuthenticationException;
+}
Added: P2PlayService/src/main/java/org/p2play/service/P2PlayVfsService.java
===================================================================
--- P2PlayService/src/main/java/org/p2play/service/P2PlayVfsService.java (rev 0)
+++ P2PlayService/src/main/java/org/p2play/service/P2PlayVfsService.java 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+import org.apache.commons.vfs.FileSystemException;
+import org.p2play.service.object.AuthenticationToken;
+
+@WebService(serviceName = "P2PlayVfsService")
+public interface P2PlayVfsService {
+ @WebMethod
+ public void addFolder(AuthenticationToken token, String newFolder)
+ throws FileSystemException;
+
+ @WebMethod
+ public void addFolder(AuthenticationToken token, String parent,
+ String newFolder) throws FileSystemException;
+
+ @WebMethod
+ public String[] getChildren(AuthenticationToken token, String parent)
+ throws FileSystemException;
+
+}
Added: P2PlayService/src/main/java/org/p2play/service/exception/AuthenticationException.java
===================================================================
--- P2PlayService/src/main/java/org/p2play/service/exception/AuthenticationException.java (rev 0)
+++ P2PlayService/src/main/java/org/p2play/service/exception/AuthenticationException.java 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.exception;
+
+public class AuthenticationException extends Exception {
+ public AuthenticationException(String message) {
+ super(message);
+ }
+}
Added: P2PlayService/src/main/java/org/p2play/service/object/AuthenticationToken.java
===================================================================
--- P2PlayService/src/main/java/org/p2play/service/object/AuthenticationToken.java (rev 0)
+++ P2PlayService/src/main/java/org/p2play/service/object/AuthenticationToken.java 2007-03-20 11:53:30 UTC (rev 42)
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.service.object;
+
+public interface AuthenticationToken {
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:07:01
|
Revision: 41
http://p2play.svn.sourceforge.net/p2play/?rev=41&view=rev
Author: tisoft
Date: 2007-03-20 04:45:23 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
P2PlayServiceServer/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 12:07:00
|
Revision: 44
http://p2play.svn.sourceforge.net/p2play/?rev=44&view=rev
Author: tisoft
Date: 2007-03-20 05:07:00 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
trunk/P2PlayAdmin/src/main/
trunk/P2PlayAdmin/src/main/java/
trunk/P2PlayAdmin/src/main/java/org/
trunk/P2PlayAdmin/src/main/java/org/p2play/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/ServiceFactory.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/VFS.gwt.xml
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileInfo.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileTreeItem.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFS.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSService.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSServiceAsync.java
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/VFS.html
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/style.css
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/
trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/VFSServiceImpl.java
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/ServiceFactory.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/ServiceFactory.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/service/ServiceFactory.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.web.service;
+
+import java.net.MalformedURLException;
+
+import javax.jws.WebService;
+
+import org.codehaus.xfire.client.XFireProxyFactory;
+import org.codehaus.xfire.service.Service;
+import org.codehaus.xfire.service.binding.ObjectServiceFactory;
+
+public class ServiceFactory {
+ private String baseURL;
+
+ private ObjectServiceFactory serviceFactory = new ObjectServiceFactory();
+
+ public ServiceFactory(String baseURL) {
+ super();
+ this.baseURL = baseURL;
+ if (!this.baseURL.endsWith("/"))
+ this.baseURL += "/";
+ }
+
+ @SuppressWarnings("unchecked")
+ public <A> A getServiceInstance(Class<A> clazz) throws MalformedURLException {
+ Service serviceModel = serviceFactory.create(clazz);
+
+ String serviceName = clazz
+ .getAnnotation(WebService.class).serviceName();
+
+ return (A)new XFireProxyFactory().create(serviceModel, baseURL
+ + serviceName);
+ }
+
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/VFS.gwt.xml
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/VFS.gwt.xml (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/VFS.gwt.xml 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?><module>
+
+ <!-- Inherit the core Web Toolkit stuff. -->
+ <inherits name="com.google.gwt.user.User"/>
+
+ <!-- Specify the app entry point class. -->
+ <entry-point class="org.p2play.web.vfs.client.VFS"/>
+
+<servlet class="org.p2play.web.vfs.server.VFSServiceImpl" path="/VFSService"/></module>
\ No newline at end of file
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileInfo.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileInfo.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileInfo.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.user.client.rpc.IsSerializable;
+
+public class FileInfo implements IsSerializable {
+ private FileInfo parent;
+
+ private String name;
+
+ public FileInfo() {
+ // needed for serialisation
+ }
+
+ public FileInfo(FileInfo parent, String name) {
+ super();
+ this.parent = parent;
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public FileInfo getParent() {
+ return parent;
+ }
+
+ public String getFullName() {
+ String full = "";
+ if (getParent() != null)
+ full += parent.getFullName();
+
+ full += "/" + getName();
+ return full;
+ }
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileTreeItem.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileTreeItem.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/FileTreeItem.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.user.client.ui.TreeItem;
+
+public class FileTreeItem extends TreeItem {
+
+ public FileTreeItem(FileInfo fileInfo) {
+ super(fileInfo.getName());
+ setUserObject(fileInfo);
+ }
+
+ public FileInfo getFileInfo() {
+ return (FileInfo) getUserObject();
+ }
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFS.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFS.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFS.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.PasswordTextBox;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Tree;
+import com.google.gwt.user.client.ui.TreeItem;
+import com.google.gwt.user.client.ui.TreeListener;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * @author markus
+ *
+ */
+public class VFS implements EntryPoint {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
+ */
+ public void onModuleLoad() {
+ final Tree tree = new Tree();
+ final TreeItem root = new FileTreeItem(new FileInfo(null, "/"));
+
+ tree.addItem(root);
+
+ updateChildren(root);
+
+ tree.addTreeListener(new TreeListener() {
+ public void onTreeItemSelected(TreeItem arg0) {
+ // do nothing
+ }
+
+ public void onTreeItemStateChanged(TreeItem arg0) {
+ if (arg0.getState()) {
+ for (int i = 0; i < arg0.getChildCount(); i++) {
+ updateChildren(arg0.getChild(i));
+ }
+ }
+
+ }
+ });
+
+ RootPanel.get().add(tree);
+
+ final TextBox createDirectoryBox = new TextBox();
+ Button createDirectoryButton = new Button("Verzeichnis erstellen");
+ createDirectoryButton.addClickListener(new ClickListener() {
+ public void onClick(Widget arg0) {
+ final TreeItem selectedItem = tree.getSelectedItem();
+ VFSService.Util.getInstance().addFolder(
+ new FileInfo((FileInfo) selectedItem.getUserObject(),
+ createDirectoryBox.getText()),
+ new AsyncCallback() {
+ public void onFailure(Throwable arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onSuccess(Object arg0) {
+ if (createDirectoryBox.getText()
+ .startsWith("/"))
+ updateChildren(root);
+ else
+ updateChildren(selectedItem);
+ }
+ });
+ }
+ });
+
+ RootPanel.get().add(createDirectoryBox);
+ RootPanel.get().add(createDirectoryButton);
+
+ createLoginDialog().show();
+
+ }
+
+ private void updateChildren(final TreeItem item) {
+ VFSService.Util.getInstance().getChildren(
+ (FileInfo) item.getUserObject(), new AsyncCallback() {
+ public void onFailure(Throwable arg0) {
+ arg0.printStackTrace();
+
+ }
+
+ public void onSuccess(Object arg0) {
+ item.removeItems();
+ FileInfo[] children = (FileInfo[]) arg0;
+ for (int i = 0; i < children.length; i++) {
+ item.addItem(new FileTreeItem(children[i]));
+ }
+ }
+ });
+ }
+
+ private DialogBox createLoginDialog() {
+ final DialogBox dialogBox = new DialogBox();
+ dialogBox.setTitle("Login");
+ final TextBox userTextBox = new TextBox();
+ final PasswordTextBox passwordTextBox = new PasswordTextBox();
+ Button loginButton = new Button("Login");
+ loginButton.addClickListener(new ClickListener() {
+ public void onClick(Widget arg0) {
+ VFSService.Util.getInstance().login(userTextBox.getText(),
+ passwordTextBox.getText().toCharArray(),
+ new AsyncCallback() {
+ public void onFailure(Throwable arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onSuccess(Object arg0) {
+ if (Boolean.TRUE.equals(arg0))
+ dialogBox.hide();
+ else
+ System.out.println("Login incorrect");
+ }
+ });
+
+ }
+ });
+
+ VerticalPanel flowPanel = new VerticalPanel();
+
+ flowPanel.add(userTextBox);
+ flowPanel.add(passwordTextBox);
+ flowPanel.add(loginButton);
+
+ dialogBox.setWidget(flowPanel);
+
+ return dialogBox;
+ }
+
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSService.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSService.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSService.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
+
+/**
+ * @author markus
+ *
+ */
+public interface VFSService extends RemoteService {
+
+ public static final String SERVICE_URI = "/VFSService";
+
+ public static class Util {
+
+ public static VFSServiceAsync getInstance() {
+
+ VFSServiceAsync instance = (VFSServiceAsync) GWT
+ .create(VFSService.class);
+ ServiceDefTarget target = (ServiceDefTarget) instance;
+ target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
+ return instance;
+ }
+ }
+
+ FileInfo[] getChildren(FileInfo parent);
+
+ void addFolder(FileInfo newFolder);
+
+ boolean login(String user, char[] password);
+
+ void logout();
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSServiceAsync.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSServiceAsync.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/client/VFSServiceAsync.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.p2play.web.vfs.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+/**
+ * @author markus
+ *
+ */
+public interface VFSServiceAsync {
+
+ void getChildren(FileInfo parent, AsyncCallback callback);
+
+ void addFolder(FileInfo newFolder, AsyncCallback callback);
+
+ void login(String user, char[] password, AsyncCallback callback);
+
+ void logout(AsyncCallback callback);
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/VFS.html
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/VFS.html (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/VFS.html 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,48 @@
+<html>
+ <head>
+
+ <!-- -->
+ <!-- Any title is fine -->
+ <!-- -->
+ <title>Wrapper HTML for VFS</title>
+
+ <!-- -->
+ <!-- Use normal html, such as style -->
+ <!-- -->
+ <style>
+ body,td,a,div,.p{font-family:arial,sans-serif}
+ div,td{color:#000000}
+ a:link,.w,.w a:link{color:#0000cc}
+ a:visited{color:#551a8b}
+ a:active{color:#ff0000}
+ </style>
+
+ <link rel="stylesheet" href="css/style.css">
+
+ <!-- -->
+ <!-- The module reference below is the link -->
+ <!-- between html and your Web Toolkit module -->
+ <!-- -->
+ <meta name='gwt:module' content='org.p2play.web.vfs.VFS'>
+
+ </head>
+
+ <!-- -->
+ <!-- The body can have arbitrary html, or -->
+ <!-- you can leave the body empty if you want -->
+ <!-- to create a completely dynamic ui -->
+ <!-- -->
+ <body>
+
+ <!-- -->
+ <!-- This script is required bootstrap stuff. -->
+ <!-- You can put it in the HEAD, but startup -->
+ <!-- is slightly faster if you include it here. -->
+ <!-- -->
+ <script language="javascript" src="gwt.js"></script>
+
+ <!-- OPTIONAL: include this if you want history support -->
+ <iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
+
+ </body>
+</html>
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/style.css
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/style.css (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/public/css/style.css 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,173 @@
+body {
+ background-color: white;
+ color: black;
+ font-family: Arial, sans-serif;
+ font-size: smaller;
+ margin: 20px 20px 20px 20px;
+}
+
+code {
+ font-size: small;
+}
+
+a {
+ color: darkblue;
+}
+
+a:visited {
+ color: darkblue;
+}
+
+.gwt-BorderedPanel {
+}
+
+.gwt-Button {
+}
+
+.gwt-Canvas {
+}
+
+.gwt-CheckBox {
+ font-size: smaller;
+}
+
+.gwt-DialogBox {
+ sborder: 8px solid #C3D9FF;
+ border: 2px outset;
+ background-color: white;
+}
+
+.gwt-DialogBox .Caption {
+ background-color: #C3D9FF;
+ padding: 3px;
+ margin: 2px;
+ font-weight: bold;
+ cursor: default;
+}
+
+.gwt-FileUpload {
+}
+
+.gwt-Frame {
+}
+
+.gwt-HorizontalSplitter .Bar {
+ width: 8px;
+ background-color: #C3D9FF;
+}
+
+.gwt-VerticalSplitter .Bar {
+ height: 8px;
+ background-color: #C3D9FF;
+}
+
+.gwt-HTML {
+ font-size: smaller;
+}
+
+.gwt-Hyperlink {
+}
+
+.gwt-Image {
+}
+
+.gwt-Label {
+ font-size: smaller;
+}
+
+.gwt-ListBox {
+}
+
+.gwt-MenuBar {
+ background-color: #C3D9FF;
+ border: 1px solid #87B3FF;
+ cursor: default;
+}
+
+.gwt-MenuBar .gwt-MenuItem {
+ padding: 1px 4px 1px 4px;
+ font-size: smaller;
+ cursor: default;
+}
+
+.gwt-MenuBar .gwt-MenuItem-selected {
+ background-color: #E8EEF7;
+}
+
+.gwt-PasswordTextBox {
+}
+
+.gwt-RadioButton {
+ font-size: smaller;
+}
+
+.gwt-TabPanel {
+}
+
+.gwt-TabPanelBottom {
+ border-left: 1px solid #87B3FF;
+}
+
+.gwt-TabBar {
+ background-color: #C3D9FF;
+ font-size: smaller;
+}
+
+.gwt-TabBar .gwt-TabBarFirst {
+ height: 100%;
+ border-bottom: 1px solid #87B3FF;
+ padding-left: 3px;
+}
+
+.gwt-TabBar .gwt-TabBarRest {
+ border-bottom: 1px solid #87B3FF;
+ padding-right: 3px;
+}
+
+.gwt-TabBar .gwt-TabBarItem {
+ border-top: 1px solid #C3D9FF;
+ border-bottom: 1px solid #87B3FF;
+ padding: 2px;
+ cursor: pointer;
+ cursor: hand;
+}
+
+.gwt-TabBar .gwt-TabBarItem-selected {
+ font-weight: bold;
+ background-color: #E8EEF7;
+ border-top: 1px solid #87B3FF;
+ border-left: 1px solid #87B3FF;
+ border-right: 1px solid #87B3FF;
+ border-bottom: 1px solid #E8EEF7;
+ padding: 2px;
+ cursor: default;
+}
+
+.gwt-TextArea {
+}
+
+.gwt-TextBox {
+}
+
+.gwt-Tree {
+}
+
+.gwt-Tree .gwt-TreeItem {
+ font-size: smaller;
+}
+
+.gwt-Tree .gwt-TreeItem-selected {
+ background-color: #C3D9FF;
+}
+
+.gwt-StackPanel {
+}
+
+.gwt-StackPanel .gwt-StackPanelItem {
+ background-color: #C3D9FF;
+ cursor: pointer;
+ cursor: hand;
+}
+
+.gwt-StackPanel .gwt-StackPanelItem-selected {
+}
Added: trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/VFSServiceImpl.java
===================================================================
--- trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/VFSServiceImpl.java (rev 0)
+++ trunk/P2PlayAdmin/src/main/java/org/p2play/web/vfs/server/VFSServiceImpl.java 2007-03-20 12:07:00 UTC (rev 44)
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2007 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */package org.p2play.web.vfs.server;
+
+import javax.servlet.http.HttpSession;
+
+import org.p2play.service.AuthenticationService;
+import org.p2play.service.P2PlayVfsService;
+import org.p2play.service.object.AuthenticationToken;
+import org.p2play.web.service.ServiceFactory;
+import org.p2play.web.vfs.client.FileInfo;
+import org.p2play.web.vfs.client.VFSService;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+public class VFSServiceImpl extends RemoteServiceServlet implements VFSService {
+ private static final ServiceFactory serviceFactory = new ServiceFactory(
+ "http://localhost:8081/");
+
+ public FileInfo[] getChildren(FileInfo parent) {
+ HttpSession session = getThreadLocalRequest().getSession();
+
+ if (session != null)
+ System.out.println(session.getAttribute("use"));
+
+ try {
+ P2PlayVfsService service = serviceFactory
+ .getServiceInstance(P2PlayVfsService.class);
+
+ String[] children = service.getChildren(getTokenFromSession(),
+ parent.getFullName());
+ FileInfo[] childStrings = new FileInfo[children.length];
+
+ for (int i = 0; i < children.length; i++) {
+ childStrings[i] = new FileInfo(parent, children[i]);
+ }
+
+ return childStrings;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void addFolder(FileInfo newFolder) {
+ HttpSession session = getThreadLocalRequest().getSession();
+
+ if (session != null)
+ System.out.println(session.getAttribute("use"));
+
+ try {
+ P2PlayVfsService service = serviceFactory
+ .getServiceInstance(P2PlayVfsService.class);
+ service.addFolder(getTokenFromSession(), newFolder.getFullName());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public boolean login(String user, char[] password) {
+ HttpSession session = getThreadLocalRequest().getSession(true);
+ try {
+ AuthenticationService service = serviceFactory
+ .getServiceInstance(AuthenticationService.class);
+ AuthenticationToken token = service.login(user, password);
+ session.setAttribute("user", user);
+ session.setAttribute("token", token);
+ return true;
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ session.invalidate();
+ return false;
+ }
+ }
+
+ private AuthenticationToken getTokenFromSession() {
+ return (AuthenticationToken) getThreadLocalRequest().getSession()
+ .getAttribute("token");
+ }
+
+ public void logout() {
+ HttpSession session = getThreadLocalRequest().getSession();
+
+ session.invalidate();
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-20 11:44:41
|
Revision: 40
http://p2play.svn.sourceforge.net/p2play/?rev=40&view=rev
Author: tisoft
Date: 2007-03-20 04:44:36 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Initial import.
Added Paths:
-----------
P2PlayService/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-13 11:37:31
|
Revision: 35
http://p2play.svn.sourceforge.net/p2play/?rev=35&view=rev
Author: tisoft
Date: 2007-03-13 03:29:07 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
changed to use maven2 to build the project
Modified Paths:
--------------
trunk/P2PlayBoot/.classpath
trunk/P2PlayBoot/.project
trunk/P2PlayBoot/.settings/org.eclipse.jdt.ui.prefs
trunk/P2PlayBoot/.settings/org.eclipse.wst.common.component
trunk/P2PlayBoot/src/main/java/org/p2play/boot/pastry/Pastry.java
Added Paths:
-----------
trunk/P2PlayBoot/pom.xml
trunk/P2PlayBoot/src/main/
trunk/P2PlayBoot/src/main/java/
trunk/P2PlayBoot/src/main/java/org/
trunk/P2PlayBoot/src/main/resources/
trunk/P2PlayBoot/src/main/resources/META-INF/
trunk/P2PlayBoot/src/main/resources/user.params
Removed Paths:
-------------
trunk/P2PlayBoot/.settings/org.eclipse.jdt.core.prefs
trunk/P2PlayBoot/lib/
trunk/P2PlayBoot/src/META-INF/
trunk/P2PlayBoot/src/org/
Modified: trunk/P2PlayBoot/.classpath
===================================================================
--- trunk/P2PlayBoot/.classpath 2007-01-22 14:32:24 UTC (rev 34)
+++ trunk/P2PlayBoot/.classpath 2007-03-13 10:29:07 UTC (rev 35)
@@ -1,11 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="src/main/resources" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry exported="true" kind="lib" path="lib/commons-vfs-20070107.jar" sourcepath="lib/sources/commons-vfs-20070107-src.zip"/>
- <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.jar" sourcepath="lib/sources/commons-logging-1.1-src.zip"/>
- <classpathentry exported="true" kind="lib" path="lib/xstream-1.1.3.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/xpp3-1.1.3.4d_b2.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/FreePastry.jar" sourcepath="lib/sources/FreePastry-source.zip"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: trunk/P2PlayBoot/.project
===================================================================
--- trunk/P2PlayBoot/.project 2007-01-22 14:32:24 UTC (rev 34)
+++ trunk/P2PlayBoot/.project 2007-03-13 10:29:07 UTC (rev 35)
@@ -20,9 +20,15 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
Deleted: trunk/P2PlayBoot/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/P2PlayBoot/.settings/org.eclipse.jdt.core.prefs 2007-01-22 14:32:24 UTC (rev 34)
+++ trunk/P2PlayBoot/.settings/org.eclipse.jdt.core.prefs 2007-03-13 10:29:07 UTC (rev 35)
@@ -1,7 +0,0 @@
-#Tue Jan 16 23:20:09 CET 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
Modified: trunk/P2PlayBoot/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- trunk/P2PlayBoot/.settings/org.eclipse.jdt.ui.prefs 2007-01-22 14:32:24 UTC (rev 34)
+++ trunk/P2PlayBoot/.settings/org.eclipse.jdt.ui.prefs 2007-03-13 10:29:07 UTC (rev 35)
@@ -1,3 +1,4 @@
-#Tue Jan 16 21:03:57 CET 2007
+#Tue Mar 13 10:36:01 CET 2007
eclipse.preferences.version=1
+internal.default.compliance=user
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n * Copyright ${year} P2Play.org\n * All rights reserved.\n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation; either\n * version 2.1 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n * \n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
Modified: trunk/P2PlayBoot/.settings/org.eclipse.wst.common.component
===================================================================
--- trunk/P2PlayBoot/.settings/org.eclipse.wst.common.component 2007-01-22 14:32:24 UTC (rev 34)
+++ trunk/P2PlayBoot/.settings/org.eclipse.wst.common.component 2007-03-13 10:29:07 UTC (rev 35)
@@ -2,5 +2,7 @@
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="P2PlayBoot">
<wb-resource deploy-path="/" source-path="/src"/>
+<wb-resource deploy-path="/" source-path="/src/main/java"/>
+<wb-resource deploy-path="/" source-path="/src/main/resources"/>
</wb-module>
</project-modules>
Added: trunk/P2PlayBoot/pom.xml
===================================================================
--- trunk/P2PlayBoot/pom.xml (rev 0)
+++ trunk/P2PlayBoot/pom.xml 2007-03-13 10:29:07 UTC (rev 35)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayBoot</artifactId>
+ <version>0.0.1</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>commons-vfs</groupId>
+ <artifactId>commons-vfs</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>FreePastry</groupId>
+ <artifactId>FreePastry</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
+
Copied: trunk/P2PlayBoot/src/main/java/org (from rev 34, trunk/P2PlayBoot/src/org)
Modified: trunk/P2PlayBoot/src/main/java/org/p2play/boot/pastry/Pastry.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/boot/pastry/Pastry.java 2007-01-22 14:32:24 UTC (rev 34)
+++ trunk/P2PlayBoot/src/main/java/org/p2play/boot/pastry/Pastry.java 2007-03-13 10:29:07 UTC (rev 35)
@@ -109,7 +109,7 @@
Environment environment = new Environment(null, null, null,
NTPTimeSource.getTimeSource(), logManager, new SimpleParameters(
- new String[]{"mmog"}, null), null);
+ new String[]{"freepastry","user"}, null), null);
NodeIdFactory nidFactory = new RandomNodeIdFactory(environment);
SocketPastryNodeFactory factory = new SocketPastryNodeFactory(
nidFactory, externalAddress, localPort, environment, null);
Copied: trunk/P2PlayBoot/src/main/resources/META-INF (from rev 34, trunk/P2PlayBoot/src/META-INF)
Added: trunk/P2PlayBoot/src/main/resources/user.params
===================================================================
--- trunk/P2PlayBoot/src/main/resources/user.params (rev 0)
+++ trunk/P2PlayBoot/src/main/resources/user.params 2007-03-13 10:29:07 UTC (rev 35)
@@ -0,0 +1,43 @@
+#default log level
+loglevel = INFO
+
+
+
+# NAT/UPnP settings
+find_firewall_policy = never
+
+nat_network_prefixes = 127.0.0.1;10.;192.168.
+# Enable and set this if you have already set up port forwarding and know the external address
+#external_address = 123.45.67.89:1234
+#enable this if you set up port forwarding (on the same port), but you don't
+#know the external address and you don't have UPnP enabled
+#this is useful for a firwall w/o UPnP support, and your IP address isn't static
+probe_for_external_address = false
+# values how to probe
+pastry_proxy_connectivity_timeout = 15000
+pastry_proxy_connectivity_tries = 3
+# possible values: always, never, prefix (prefix is if the localAddress matches any of the nat_network_prefixes
+# whether to search for a nat using UPnP
+nat_search_policy = never
+# whether to verify connectivity
+firewall_test_policy = always
+# policy for setting port forwarding the state of the firewall if there is already a conflicting rule: overwrite, fail (throw exception), change (use different port)
+# you may want to set this to overwrite or fail on the bootstrap nodes, but most freepastry applications can run on any available port, so the default is change
+nat_state_policy = change
+# the name of the application in the firewall, set this if you want your application to have a more specific name
+nat_app_name = freepastry
+# how long to wait for responses from the firewall, in millis
+nat_discovery_timeout = 5000
+# how many searches to try to find a free firewall port
+nat_find_port_max_tries = 10
+# uncomment this to use UPnP NAT port forwarding, you need to include in the classpath: commons-jxpath-1.1.jar:commons-logging.jar:sbbi-upnplib-xxx.jar
+nat_handler_class = rice.pastry.socket.nat.sbbi.SBBINatHandler
+# hairpinning:
+# default "prefix" requires more bandwidth if you are behind a NAT. It enables multiple IP
+# addresses in the NodeHandle if you are behind a NAT. These are usually the internet routable address,
+# and the LAN address (usually 192.168.x.x)
+# you can set this to never if any of the following conditions hold:
+# a) you are the only FreePastry node behind this address
+# b) you firewall supports hairpinning see
+# http://scm.sipfoundry.org/rep/ietf-drafts/behave/draft-ietf-behave-nat-udp-03.html#rfc.section.6
+nat_nodehandle_multiaddress = prefix
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-13 10:46:21
|
Revision: 39
http://p2play.svn.sourceforge.net/p2play/?rev=39&view=rev
Author: tisoft
Date: 2007-03-13 03:46:22 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
added target to ignore
Property Changed:
----------------
trunk/P2Play/
trunk/P2PlayBoot/
Property changes on: trunk/P2Play
___________________________________________________________________
Name: svn:ignore
- bin
+ bin
target
Property changes on: trunk/P2PlayBoot
___________________________________________________________________
Name: svn:ignore
- bin
+ bin
target
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-13 10:43:24
|
Revision: 38
http://p2play.svn.sourceforge.net/p2play/?rev=38&view=rev
Author: tisoft
Date: 2007-03-13 03:43:25 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
unneded
Modified Paths:
--------------
trunk/P2Play/src/main/java/org/p2play/region/impl/SingleStaticNetworkRegionManager.java
Modified: trunk/P2Play/src/main/java/org/p2play/region/impl/SingleStaticNetworkRegionManager.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/region/impl/SingleStaticNetworkRegionManager.java 2007-03-13 10:42:43 UTC (rev 37)
+++ trunk/P2Play/src/main/java/org/p2play/region/impl/SingleStaticNetworkRegionManager.java 2007-03-13 10:43:25 UTC (rev 38)
@@ -22,8 +22,6 @@
import rice.environment.time.TimeSource;
import rice.p2p.commonapi.Node;
-import rice.p2p.scribe.Scribe;
-import rice.p2p.scribe.ScribeImpl;
public final class SingleStaticNetworkRegionManager implements Runnable,
RegionManager {
@@ -57,7 +55,6 @@
networkHandler = new NetworkHandler(serializer, this, node);
- Scribe scribe = new ScribeImpl(node, "gamestate");
serverHandler = new ServerHandler(this, dataManager, serverFactory);
new Thread(this).start();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-13 10:42:49
|
Revision: 37
http://p2play.svn.sourceforge.net/p2play/?rev=37&view=rev
Author: tisoft
Date: 2007-03-13 03:42:43 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
organized imports
Modified Paths:
--------------
trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java
trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java
trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java 2007-03-13 10:36:39 UTC (rev 36)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java 2007-03-13 10:42:43 UTC (rev 37)
@@ -1,10 +1,6 @@
package org.p2play.lobby;
-import java.util.Vector;
-import rice.p2p.commonapi.Application;
-import rice.p2p.scribe.ScribeClient;
-
public interface Lobby{
public void publishGame(GameInfo gameInfo);
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java 2007-03-13 10:36:39 UTC (rev 36)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java 2007-03-13 10:42:43 UTC (rev 37)
@@ -4,7 +4,6 @@
import java.net.ServerSocket;
import java.net.Socket;
-import rice.p2p.commonapi.Endpoint;
import rice.p2p.commonapi.appsocket.AppSocket;
import rice.p2p.commonapi.appsocket.AppSocketReceiver;
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java 2007-03-13 10:36:39 UTC (rev 36)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java 2007-03-13 10:42:43 UTC (rev 37)
@@ -6,17 +6,10 @@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.net.Socket;
-import java.nio.Buffer;
import java.nio.ByteBuffer;
-import java.nio.channels.SocketChannel;
-import rice.p2p.commonapi.Application;
import rice.p2p.commonapi.Endpoint;
-import rice.p2p.commonapi.Id;
-import rice.p2p.commonapi.Message;
-import rice.p2p.commonapi.Node;
import rice.p2p.commonapi.NodeHandle;
-import rice.p2p.commonapi.RouteMessage;
import rice.p2p.commonapi.appsocket.AppSocket;
import rice.p2p.commonapi.appsocket.AppSocketReceiver;
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java 2007-03-13 10:36:39 UTC (rev 36)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java 2007-03-13 10:42:43 UTC (rev 37)
@@ -2,8 +2,6 @@
import java.io.IOException;
-import org.p2play.io.Serializer;
-
import rice.p2p.commonapi.Endpoint;
import rice.p2p.commonapi.Message;
import rice.p2p.commonapi.NodeHandle;
Modified: trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java 2007-03-13 10:36:39 UTC (rev 36)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java 2007-03-13 10:42:43 UTC (rev 37)
@@ -6,7 +6,6 @@
import org.p2play.lobby.GameInfo;
import rice.p2p.commonapi.Endpoint;
-import rice.p2p.commonapi.Message;
import rice.p2p.commonapi.rawserialization.InputBuffer;
import rice.p2p.commonapi.rawserialization.OutputBuffer;
import rice.p2p.commonapi.rawserialization.RawMessage;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-03-13 10:36:41
|
Revision: 36
http://p2play.svn.sourceforge.net/p2play/?rev=36&view=rev
Author: tisoft
Date: 2007-03-13 03:36:39 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
changed to use maven2 to build the project
Modified Paths:
--------------
trunk/P2Play/.classpath
trunk/P2Play/.project
trunk/P2Play/.settings/org.eclipse.wst.common.component
trunk/P2Play/src/main/java/org/p2play/data/Data.java
Added Paths:
-----------
trunk/P2Play/pom.xml
trunk/P2Play/src/main/
trunk/P2Play/src/main/java/
trunk/P2Play/src/main/java/org/
trunk/P2Play/src/main/java/org/p2play/
trunk/P2Play/src/main/java/org/p2play/lobby/
trunk/P2Play/src/main/java/org/p2play/lobby/ClientServerGameInfo.java
trunk/P2Play/src/main/java/org/p2play/lobby/GameInfo.java
trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java
trunk/P2Play/src/main/java/org/p2play/lobby/LobbyListener.java
trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java
trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/
trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyMessage.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java
trunk/P2Play/src/main/java/org/p2play/lobby/impl/ScribeLobby.java
trunk/P2Play/src/main/java/org/p2play/security/
trunk/P2Play/src/main/java/org/p2play/security/Signable.java
trunk/P2Play/src/main/java/org/p2play/security/SignablePublicKey.java
trunk/P2Play/src/main/java/org/p2play/security/Signature.java
trunk/P2Play/src/main/resources/
trunk/P2Play/src/main/resources/META-INF/
trunk/P2Play/src/main/resources/META-INF/MANIFEST.MF
Removed Paths:
-------------
trunk/P2Play/lib/
trunk/P2Play/src/META-INF/
trunk/P2Play/src/main/java/org/p2play/
trunk/P2Play/src/main/resources/META-INF/MANIFEST.MF
trunk/P2Play/src/org/
Modified: trunk/P2Play/.classpath
===================================================================
--- trunk/P2Play/.classpath 2007-03-13 10:29:07 UTC (rev 35)
+++ trunk/P2Play/.classpath 2007-03-13 10:36:39 UTC (rev 36)
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry exported="true" kind="lib" path="lib/javolution.jar" sourcepath="lib/sources/javolution-4.1.0-src.zip"/>
- <classpathentry exported="true" kind="lib" path="lib/pnuts.jar" sourcepath="lib/sources/pnuts-1.2-src.zip"/>
- <classpathentry exported="true" kind="lib" path="lib/jdom.jar" sourcepath="lib/sources/jdom-1.0.zip"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/P2PlayBoot"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry exported="true" kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: trunk/P2Play/.project
===================================================================
--- trunk/P2Play/.project 2007-03-13 10:29:07 UTC (rev 35)
+++ trunk/P2Play/.project 2007-03-13 10:36:39 UTC (rev 36)
@@ -20,9 +20,15 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
Modified: trunk/P2Play/.settings/org.eclipse.wst.common.component
===================================================================
--- trunk/P2Play/.settings/org.eclipse.wst.common.component 2007-03-13 10:29:07 UTC (rev 35)
+++ trunk/P2Play/.settings/org.eclipse.wst.common.component 2007-03-13 10:36:39 UTC (rev 36)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="P2Play">
-<wb-resource deploy-path="/" source-path="/src"/>
+<wb-resource deploy-path="/" source-path="/src/main/java"/>
+<wb-resource deploy-path="/" source-path="/src/test/java"/>
</wb-module>
</project-modules>
Added: trunk/P2Play/pom.xml
===================================================================
--- trunk/P2Play/pom.xml (rev 0)
+++ trunk/P2Play/pom.xml 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>P2Play</groupId>
+ <artifactId>P2Play</artifactId>
+ <version>0.0.1</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>javolution</groupId>
+ <artifactId>javolution</artifactId>
+ <version>4.2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>pnuts</groupId>
+ <artifactId>pnuts</artifactId>
+ <version>1.2-BETA</version>
+ </dependency>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>P2Play</groupId>
+ <artifactId>P2PlayBoot</artifactId>
+ <version>0.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.2.1</version>
+ </dependency>
+ </dependencies>
+</project>
+
Copied: trunk/P2Play/src/main/java/org (from rev 26, trunk/P2Play/src/org)
Copied: trunk/P2Play/src/main/java/org/p2play (from rev 34, trunk/P2Play/src/org/p2play)
Modified: trunk/P2Play/src/main/java/org/p2play/data/Data.java
===================================================================
--- trunk/P2Play/src/org/p2play/data/Data.java 2007-01-22 14:32:24 UTC (rev 34)
+++ trunk/P2Play/src/main/java/org/p2play/data/Data.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -2,7 +2,7 @@
import java.io.Serializable;
-import de.upb.mmog.net.security.Signable;
+import org.p2play.security.Signable;
/**
* All Objects stored in the DataManager have to be subclasses of Data
Added: trunk/P2Play/src/main/java/org/p2play/lobby/ClientServerGameInfo.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/ClientServerGameInfo.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/ClientServerGameInfo.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,49 @@
+package org.p2play.lobby;
+
+import java.io.IOException;
+
+import rice.p2p.commonapi.Endpoint;
+import rice.p2p.commonapi.NodeHandle;
+import rice.p2p.commonapi.appsocket.AppSocketReceiver;
+import rice.p2p.commonapi.rawserialization.InputBuffer;
+import rice.p2p.commonapi.rawserialization.OutputBuffer;
+
+public class ClientServerGameInfo implements GameInfo{
+ private String name;
+ private NodeHandle handle;
+
+ private Endpoint endpoint;
+
+ public ClientServerGameInfo(Endpoint endpoint, InputBuffer buffer) throws IOException{
+ this.name=buffer.readUTF();
+ this.handle=endpoint.readNodeHandle(buffer);
+ }
+
+ public ClientServerGameInfo(Endpoint endpoint, String name, AppSocketReceiver receiver){
+ this(endpoint,name,endpoint.getLocalNodeHandle());
+ endpoint.accept(receiver);
+ }
+
+ protected ClientServerGameInfo(Endpoint endpoint, String name, NodeHandle handle) {
+ super();
+ this.name = name;
+ this.handle = handle;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public NodeHandle getHandle() {
+ return handle;
+ }
+
+ public void connect(AppSocketReceiver receiver){
+ endpoint.connect(handle, receiver, 60);
+ }
+
+ public void serialize(OutputBuffer buf) throws IOException {
+ buf.writeUTF(name);
+ handle.serialize(buf);
+ }
+}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/GameInfo.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/GameInfo.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/GameInfo.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,12 @@
+package org.p2play.lobby;
+
+import java.io.IOException;
+
+import rice.p2p.commonapi.NodeHandle;
+import rice.p2p.commonapi.rawserialization.OutputBuffer;
+
+public interface GameInfo {
+ public String getName();
+ public NodeHandle getHandle();
+ public void serialize(OutputBuffer buf) throws IOException;
+}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/Lobby.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,16 @@
+package org.p2play.lobby;
+
+import java.util.Vector;
+
+import rice.p2p.commonapi.Application;
+import rice.p2p.scribe.ScribeClient;
+
+public interface Lobby{
+ public void publishGame(GameInfo gameInfo);
+
+ public void unpublishGame(GameInfo gameInfo);
+
+ public void addLobbyListener(LobbyListener listener);
+
+ public void removeLobbyListener(LobbyListener listener);
+}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/LobbyListener.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/LobbyListener.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/LobbyListener.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,6 @@
+package org.p2play.lobby;
+
+public interface LobbyListener {
+ public void gameCreated(GameInfo gameInfo);
+ public void gameRemoved(GameInfo gameInfo);
+}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/LobbyServerSocket.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,58 @@
+package org.p2play.lobby;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import rice.p2p.commonapi.Endpoint;
+import rice.p2p.commonapi.appsocket.AppSocket;
+import rice.p2p.commonapi.appsocket.AppSocketReceiver;
+
+public class LobbyServerSocket extends ServerSocket implements AppSocketReceiver{
+
+ private Object mutex=new Object();
+
+ private LobbySocket lobbySocket;
+
+ public LobbyServerSocket() throws IOException {
+ super();
+ }
+
+ public void receiveException(AppSocket socket, Exception e) {
+ // TODO Auto-generated method stub
+ e.printStackTrace();
+ }
+
+ public void receiveSelectResult(AppSocket socket, boolean canRead, boolean canWrite) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void receiveSocket(AppSocket socket) {
+ synchronized (mutex) {
+ try {
+ lobbySocket=new LobbySocket();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ socket.register(true, true, 30000, lobbySocket);
+ mutex.notifyAll();
+ }
+
+ }
+
+ @Override
+ public Socket accept() throws IOException {
+ synchronized (mutex) {
+ try {
+ mutex.wait();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return lobbySocket;
+ }
+ }
+}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/LobbySocket.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,104 @@
+package org.p2play.lobby;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.net.Socket;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.channels.SocketChannel;
+
+import rice.p2p.commonapi.Application;
+import rice.p2p.commonapi.Endpoint;
+import rice.p2p.commonapi.Id;
+import rice.p2p.commonapi.Message;
+import rice.p2p.commonapi.Node;
+import rice.p2p.commonapi.NodeHandle;
+import rice.p2p.commonapi.RouteMessage;
+import rice.p2p.commonapi.appsocket.AppSocket;
+import rice.p2p.commonapi.appsocket.AppSocketReceiver;
+
+public class LobbySocket extends Socket implements AppSocketReceiver {
+
+ private ByteBuffer[] buffer;
+
+ private InputStream inputStream;
+
+ private PipedOutputStream pipedOutputStream;
+
+ private OutputStream outputStream;
+
+ private PipedInputStream pipedInputStream;
+
+ private AppSocket socket;
+
+ public LobbySocket() throws IOException {
+ buffer = new ByteBuffer[2];
+ buffer[0] = ByteBuffer.wrap(new byte[1024]);
+
+ inputStream = new PipedInputStream();
+ pipedOutputStream = new PipedOutputStream(
+ (PipedInputStream) inputStream);
+
+ outputStream = new PipedOutputStream();
+ pipedInputStream = new PipedInputStream(
+ (PipedOutputStream) outputStream);
+ }
+
+ public LobbySocket(Endpoint endpoint, NodeHandle handle) throws IOException {
+ this();
+ endpoint.connect(handle, this, 30000);
+ }
+
+ public void receiveException(AppSocket socket, Exception e) {
+ // TODO Auto-generated method stub
+ e.printStackTrace();
+ }
+
+ public void receiveSelectResult(AppSocket socket, boolean canRead,
+ boolean canWrite) {
+ try {
+ if (canRead) {
+ socket.read(buffer, 0, 1);
+ pipedOutputStream.write(buffer[0].array(),
+ buffer[0].position(), buffer[0].remaining());
+ pipedOutputStream.flush();
+ buffer[0].rewind();
+ }
+
+ if (canWrite && pipedInputStream.available() > 0) {
+ byte[] b = new byte[pipedInputStream.available()];
+ pipedInputStream.read(b);
+ buffer[1] = ByteBuffer.wrap(b);
+ long i=socket.write(buffer, 1, 1);
+ System.out.println("Wrote: "+i);
+ socket.shutdownOutput();
+ }
+
+ socket.register(true, true, 30000, this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void receiveSocket(AppSocket socket) {
+ this.socket=socket;
+ }
+
+ @Override
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ @Override
+ public OutputStream getOutputStream() {
+ return outputStream;
+ }
+
+ @Override
+ public synchronized void close() throws IOException {
+ socket.close();
+ }
+}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyDeserializer.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,43 @@
+package org.p2play.lobby.impl;
+
+import java.io.IOException;
+
+import org.p2play.io.Serializer;
+
+import rice.p2p.commonapi.Endpoint;
+import rice.p2p.commonapi.Message;
+import rice.p2p.commonapi.NodeHandle;
+import rice.p2p.commonapi.rawserialization.InputBuffer;
+import rice.p2p.commonapi.rawserialization.MessageDeserializer;
+import rice.p2p.scribe.ScribeContent;
+import rice.p2p.scribe.rawserialization.ScribeContentDeserializer;
+
+public class LobbyDeserializer implements MessageDeserializer, ScribeContentDeserializer {
+ private Endpoint endpoint;
+
+ public LobbyDeserializer(Endpoint endpoint) {
+ super();
+ this.endpoint = endpoint;
+ }
+
+ public Message deserialize(InputBuffer buf, short type, int priority,
+ NodeHandle sender) throws IOException {
+ return (Message) deserialize(buf, endpoint, type);
+ }
+
+ public ScribeContent deserializeScribeContent(InputBuffer buf,
+ Endpoint endpoint, short contentType) throws IOException {
+ return (ScribeContent) deserialize(buf, endpoint, contentType);
+ }
+
+ private Object deserialize(InputBuffer buf, Endpoint endpoint, short type)
+ throws IOException {
+ switch (type) {
+ case LobbyMessage.TYPE_PUBLISH_GAME:
+ return new PublishGameInfoMessage(endpoint, buf);
+ }
+ System.out.println("Found unknown message: " + type);
+ return null;
+ }
+
+}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyMessage.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyMessage.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/LobbyMessage.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,5 @@
+package org.p2play.lobby.impl;
+
+public interface LobbyMessage {
+ public static final short TYPE_PUBLISH_GAME=1;
+}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/PublishGameInfoMessage.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,43 @@
+package org.p2play.lobby.impl;
+
+import java.io.IOException;
+
+import org.p2play.lobby.ClientServerGameInfo;
+import org.p2play.lobby.GameInfo;
+
+import rice.p2p.commonapi.Endpoint;
+import rice.p2p.commonapi.Message;
+import rice.p2p.commonapi.rawserialization.InputBuffer;
+import rice.p2p.commonapi.rawserialization.OutputBuffer;
+import rice.p2p.commonapi.rawserialization.RawMessage;
+import rice.p2p.scribe.rawserialization.RawScribeContent;
+
+public class PublishGameInfoMessage implements RawMessage,RawScribeContent,LobbyMessage {
+
+ private GameInfo gameInfo;
+
+ public PublishGameInfoMessage(GameInfo gameInfo) {
+ this.gameInfo=gameInfo;
+ }
+
+ public PublishGameInfoMessage(Endpoint endpoint, InputBuffer buffer) throws IOException{
+ gameInfo=new ClientServerGameInfo(endpoint, buffer);
+ }
+
+ public int getPriority() {
+ return 0;
+ }
+
+ public short getType() {
+ return TYPE_PUBLISH_GAME;
+ }
+
+ public GameInfo getGameInfo() {
+ return gameInfo;
+ }
+
+ public void serialize(OutputBuffer buf) throws IOException {
+ buf.writeShort(getType());
+ gameInfo.serialize(buf);
+ }
+}
Added: trunk/P2Play/src/main/java/org/p2play/lobby/impl/ScribeLobby.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/lobby/impl/ScribeLobby.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/lobby/impl/ScribeLobby.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,123 @@
+package org.p2play.lobby.impl;
+
+import javolution.util.FastCollection;
+import javolution.util.FastList;
+import javolution.util.FastCollection.Record;
+
+import org.p2play.lobby.GameInfo;
+import org.p2play.lobby.Lobby;
+import org.p2play.lobby.LobbyListener;
+
+import rice.p2p.commonapi.Application;
+import rice.p2p.commonapi.Endpoint;
+import rice.p2p.commonapi.Id;
+import rice.p2p.commonapi.Message;
+import rice.p2p.commonapi.Node;
+import rice.p2p.commonapi.NodeHandle;
+import rice.p2p.commonapi.RouteMessage;
+import rice.p2p.scribe.Scribe;
+import rice.p2p.scribe.ScribeClient;
+import rice.p2p.scribe.ScribeContent;
+import rice.p2p.scribe.ScribeImpl;
+import rice.p2p.scribe.Topic;
+
+public class ScribeLobby implements Lobby, Application, ScribeClient {
+
+ private FastCollection<LobbyListener> listeners;
+
+ private FastCollection<GameInfo> publishedGames;
+
+ private Scribe scribe;
+
+ private Endpoint endpoint;
+
+ private Topic topic;
+
+ public ScribeLobby(Node node) {
+
+ listeners=new FastList<LobbyListener>();
+ publishedGames=new FastList<GameInfo>();
+ endpoint=node.buildEndpoint(this, "lobby_endpoint");
+ LobbyDeserializer deserializer=new LobbyDeserializer(endpoint);
+ endpoint.setDeserializer(deserializer);
+ scribe=new ScribeImpl(node,"lobby_scribe");
+ scribe.setContentDeserializer(deserializer);
+ topic=new Topic(node.getIdFactory(),"lobby_toppc");
+
+ endpoint.register();
+ scribe.subscribe(topic, this);
+ }
+
+ public void addLobbyListener(LobbyListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeLobbyListener(LobbyListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void unpublishGame(GameInfo gameInfo) {
+ publishedGames.remove(gameInfo);
+ }
+
+ public void publishGame(GameInfo gameInfo) {
+ publishedGames.add(gameInfo);
+
+ scribe.publish(topic, new PublishGameInfoMessage(gameInfo));
+ }
+
+ public void deliver(Id id, Message message) {
+ handleMessage(message);
+ }
+
+ private void handleMessage(Object message) {
+ if (message instanceof PublishGameInfoMessage) {
+ PublishGameInfoMessage pgi = (PublishGameInfoMessage) message;
+ firePublish(pgi.getGameInfo());
+ }
+ }
+
+ private void firePublish(GameInfo gameInfo) {
+ for (Record r = listeners.head(), end = listeners.tail(); (r = r
+ .getNext()) != end;) {
+ listeners.valueOf(r).gameCreated(gameInfo);
+ }
+ }
+
+ public boolean forward(RouteMessage message) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ public void update(NodeHandle handle, boolean joined) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean anycast(Topic topic, ScribeContent content) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void childAdded(Topic topic, NodeHandle child) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void childRemoved(Topic topic, NodeHandle child) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deliver(Topic topic, ScribeContent content) {
+ handleMessage(content);
+
+ }
+
+ public void subscribeFailed(Topic topic) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
Added: trunk/P2Play/src/main/java/org/p2play/security/Signable.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/security/Signable.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/security/Signable.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,8 @@
+package org.p2play.security;
+
+
+public interface Signable{
+ public void addSignature(Signature signature);
+ public byte[] getData();
+ public Signature[] getSignatures();
+}
Added: trunk/P2Play/src/main/java/org/p2play/security/SignablePublicKey.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/security/SignablePublicKey.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/security/SignablePublicKey.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,54 @@
+package org.p2play.security;
+
+
+import java.security.PublicKey;
+
+import rice.p2p.commonapi.Id;
+
+public class SignablePublicKey implements PublicKey, Signable {
+
+ private PublicKey publicKey;
+
+ private Signature[] signatures;
+
+ private Id id;
+
+ public SignablePublicKey(Id id, PublicKey publicKey) {
+ super();
+ this.id = id;
+ this.publicKey = publicKey;
+ signatures=new Signature[0];
+ }
+
+ public String getAlgorithm() {
+ return publicKey.getAlgorithm();
+ }
+
+ public byte[] getEncoded() {
+ return publicKey.getEncoded();
+ }
+
+ public String getFormat() {
+ return publicKey.getFormat();
+ }
+
+public PublicKey getPublicKey() {
+ return publicKey;
+}
+
+ public void addSignature(Signature signature) {
+
+ }
+
+ public byte[] getData() {
+ return getEncoded();
+ }
+
+ public Signature[] getSignatures() {
+ return signatures;
+ }
+
+ public Id getId() {
+ return id;
+ }
+}
Added: trunk/P2Play/src/main/java/org/p2play/security/Signature.java
===================================================================
--- trunk/P2Play/src/main/java/org/p2play/security/Signature.java (rev 0)
+++ trunk/P2Play/src/main/java/org/p2play/security/Signature.java 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,26 @@
+package org.p2play.security;
+
+
+import java.io.Serializable;
+
+public class Signature implements Serializable{
+ private byte[] signature;
+ private SignablePublicKey signer;
+
+
+
+ public byte[] getSignature() {
+ return signature;
+ }
+
+ public SignablePublicKey getSigner() {
+ return signer;
+ }
+
+ public Signature(SignablePublicKey signer, byte[] signature) {
+ super();
+ this.signer = signer;
+ this.signature = signature;
+ }
+
+}
Copied: trunk/P2Play/src/main/resources/META-INF (from rev 26, trunk/P2Play/src/META-INF)
Deleted: trunk/P2Play/src/main/resources/META-INF/MANIFEST.MF
===================================================================
--- trunk/P2Play/src/META-INF/MANIFEST.MF 2007-01-22 12:36:37 UTC (rev 26)
+++ trunk/P2Play/src/main/resources/META-INF/MANIFEST.MF 2007-03-13 10:36:39 UTC (rev 36)
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
Copied: trunk/P2Play/src/main/resources/META-INF/MANIFEST.MF (from rev 34, trunk/P2Play/src/META-INF/MANIFEST.MF)
===================================================================
--- trunk/P2Play/src/main/resources/META-INF/MANIFEST.MF (rev 0)
+++ trunk/P2Play/src/main/resources/META-INF/MANIFEST.MF 2007-03-13 10:36:39 UTC (rev 36)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-01-22 14:32:24
|
Revision: 34
http://p2play.svn.sourceforge.net/p2play/?rev=34&view=rev
Author: tisoft
Date: 2007-01-22 06:32:24 -0800 (Mon, 22 Jan 2007)
Log Message:
-----------
export P2PlayBoot project
Modified Paths:
--------------
trunk/P2Play/.classpath
Modified: trunk/P2Play/.classpath
===================================================================
--- trunk/P2Play/.classpath 2007-01-22 14:25:22 UTC (rev 33)
+++ trunk/P2Play/.classpath 2007-01-22 14:32:24 UTC (rev 34)
@@ -5,6 +5,6 @@
<classpathentry exported="true" kind="lib" path="lib/javolution.jar" sourcepath="lib/sources/javolution-4.1.0-src.zip"/>
<classpathentry exported="true" kind="lib" path="lib/pnuts.jar" sourcepath="lib/sources/pnuts-1.2-src.zip"/>
<classpathentry exported="true" kind="lib" path="lib/jdom.jar" sourcepath="lib/sources/jdom-1.0.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/P2PlayBoot"/>
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/P2PlayBoot"/>
<classpathentry kind="output" path="bin"/>
</classpath>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-01-22 14:25:27
|
Revision: 33
http://p2play.svn.sourceforge.net/p2play/?rev=33&view=rev
Author: tisoft
Date: 2007-01-22 06:25:22 -0800 (Mon, 22 Jan 2007)
Log Message:
-----------
moved classed
Modified Paths:
--------------
trunk/P2Play/src/org/p2play/region/impl/SingleStaticNetworkRegionManager.java
trunk/P2PlayBoot/src/org/p2play/boot/time/NTPMessage.java
trunk/P2PlayBoot/src/org/p2play/boot/time/NTPTimeSource.java
trunk/P2PlayBoot/src/org/p2play/boot/vfs/PastryFileProvider.java
trunk/P2PlayBoot/src/org/p2play/boot/vfs/PastryFileSystem.java
Added Paths:
-----------
trunk/P2Play/src/org/p2play/region/impl/TimeManager.java
trunk/P2PlayBoot/src/org/p2play/boot/pastry/
trunk/P2PlayBoot/src/org/p2play/boot/pastry/DefaultNodeHandler.java
trunk/P2PlayBoot/src/org/p2play/boot/pastry/NodeHandler.java
trunk/P2PlayBoot/src/org/p2play/boot/pastry/Pastry.java
trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/
trunk/P2PlayBoot/src/org/p2play/boot/time/
Removed Paths:
-------------
trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/NTPMessage.java
trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/NTPTimeSource.java
trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/TimeManager.java
trunk/P2PlayBoot/src/org/p2play/boot/time/TimeManager.java
trunk/P2PlayBoot/src/org/p2play/net/
Modified: trunk/P2Play/src/org/p2play/region/impl/SingleStaticNetworkRegionManager.java
===================================================================
--- trunk/P2Play/src/org/p2play/region/impl/SingleStaticNetworkRegionManager.java 2007-01-22 14:18:04 UTC (rev 32)
+++ trunk/P2Play/src/org/p2play/region/impl/SingleStaticNetworkRegionManager.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -7,7 +7,6 @@
import org.p2play.data.DataManager;
import org.p2play.io.Serializer;
-import org.p2play.net.pastry.time.TimeManager;
import org.p2play.region.Client;
import org.p2play.region.GameAction;
import org.p2play.region.GameState;
Copied: trunk/P2Play/src/org/p2play/region/impl/TimeManager.java (from rev 28, trunk/P2PlayBoot/src/org/p2play/net/pastry/time/TimeManager.java)
===================================================================
--- trunk/P2Play/src/org/p2play/region/impl/TimeManager.java (rev 0)
+++ trunk/P2Play/src/org/p2play/region/impl/TimeManager.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.region.impl;
+
+import rice.p2p.commonapi.Node;
+
+public class TimeManager {
+ private static TimeManager timeManager;
+
+ private Node node;
+
+ private long baseTime=0;
+
+ private TimeManager(Node node) {
+ super();
+ this.node = node;
+ }
+
+ public static TimeManager getTimeManager() {
+ if(timeManager==null) {
+ throw new IllegalStateException("No TimeManager created. You have to call TimeManager.create() once before using it.");
+ }
+ return timeManager;
+ }
+
+ public static TimeManager create(Node node){
+ if(timeManager==null) {
+ timeManager=new TimeManager(node);
+ }
+
+ return timeManager;
+ }
+
+ public long getGameTime(){
+ return (baseTime+node.getEnvironment().getTimeSource().currentTimeMillis())/100L;
+ }
+}
Copied: trunk/P2PlayBoot/src/org/p2play/boot/pastry/DefaultNodeHandler.java (from rev 28, trunk/P2PlayBoot/src/org/p2play/net/pastry/DefaultNodeHandler.java)
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/boot/pastry/DefaultNodeHandler.java (rev 0)
+++ trunk/P2PlayBoot/src/org/p2play/boot/pastry/DefaultNodeHandler.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -0,0 +1,73 @@
+package org.p2play.boot.pastry;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.p2play.boot.pastry.NodeHandler;
+import org.p2play.boot.pastry.Pastry;
+
+import rice.p2p.commonapi.Node;
+import rice.p2p.past.Past;
+import rice.p2p.past.PastImpl;
+import rice.p2p.scribe.Scribe;
+import rice.p2p.scribe.ScribeImpl;
+import rice.persistence.LRUCache;
+import rice.persistence.MemoryStorage;
+import rice.persistence.StorageManagerImpl;
+
+public class DefaultNodeHandler implements NodeHandler {
+ private Node node;
+
+ private Map<String, Past> pastMap = new HashMap<String, Past>();
+
+ private Map<String, Scribe> scribeMap = new HashMap<String, Scribe>();
+
+ private static DefaultNodeHandler staticNode;
+
+ public Node getNode() {
+ if (node == null)
+ throw new RuntimeException("Node not initialized!");
+ return node;
+ }
+
+ public Past getPast(String instance) {
+ Past past = pastMap.get(instance);
+
+ if (past == null) {
+ past = new PastImpl(node, new StorageManagerImpl(node
+ .getIdFactory(), new MemoryStorage(node.getIdFactory()),
+ new LRUCache(new MemoryStorage(node.getIdFactory()), 100,
+ node.getEnvironment())), 3, instance);
+
+ pastMap.put(instance, past);
+ }
+
+ return past;
+ }
+
+ public Scribe getScribe(String instance) {
+ Scribe scribe = scribeMap.get(instance);
+
+ if (scribe == null) {
+ scribe = new ScribeImpl(getNode(), instance);
+
+ scribeMap.put(instance, scribe);
+ }
+
+ return scribe;
+ }
+
+ public DefaultNodeHandler(Node node) {
+ super();
+ this.node = node;
+ this.pastMap=new HashMap<String, Past>();
+ this.scribeMap=new HashMap<String, Scribe>();
+ }
+
+}
Copied: trunk/P2PlayBoot/src/org/p2play/boot/pastry/NodeHandler.java (from rev 28, trunk/P2PlayBoot/src/org/p2play/net/pastry/NodeHandler.java)
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/boot/pastry/NodeHandler.java (rev 0)
+++ trunk/P2PlayBoot/src/org/p2play/boot/pastry/NodeHandler.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -0,0 +1,11 @@
+package org.p2play.boot.pastry;
+
+import rice.p2p.commonapi.Node;
+import rice.p2p.past.Past;
+import rice.p2p.scribe.Scribe;
+
+public interface NodeHandler {
+ public Node getNode();
+ public Past getPast(String instance);
+ public Scribe getScribe(String instance);
+}
Copied: trunk/P2PlayBoot/src/org/p2play/boot/pastry/Pastry.java (from rev 28, trunk/P2PlayBoot/src/org/p2play/net/pastry/Pastry.java)
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/boot/pastry/Pastry.java (rev 0)
+++ trunk/P2PlayBoot/src/org/p2play/boot/pastry/Pastry.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2006 P2Play.org
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.p2play.boot.pastry;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+
+import org.p2play.boot.time.NTPTimeSource;
+
+import rice.environment.Environment;
+import rice.environment.logging.LogManager;
+import rice.environment.params.simple.SimpleParameters;
+import rice.p2p.commonapi.Node;
+import rice.pastry.NodeIdFactory;
+import rice.pastry.PastryNode;
+import rice.pastry.socket.SocketPastryNodeFactory;
+import rice.pastry.standard.RandomNodeIdFactory;
+
+public class Pastry {
+ /**
+ * Boot into the Pastry Network
+ *
+ * @param remoteHost
+ * the remote host to boot into
+ * @param remotePort
+ * the port on the remote host to boot into
+ * @param externalHost
+ * our external IP
+ * @param localPort
+ * the port we bind to
+ * @return The local PastryNode, that is connected in the Pastry Network
+ * @throws IOException
+ */
+ public static Node boot(String remoteHost, int remotePort,
+ String externalHost, int localPort) throws IOException {
+ return boot(InetAddress.getByName(remoteHost), remotePort, InetAddress
+ .getByName(externalHost), localPort);
+ }
+
+ /**
+ * Boot into the Pastry Network
+ *
+ * @param remoteHost
+ * the remote host to boot into
+ * @param remotePort
+ * the port on the remote host to boot into
+ * @param externalHost
+ * our external IP
+ * @param localPort
+ * the port we bind to
+ * @return The local PastryNode, that is connected in the Pastry Network
+ * @throws IOException
+ */
+ public static Node boot(InetAddress remoteHost, int remotePort,
+ InetAddress externalHost, int localPort) throws IOException {
+ return boot(new InetSocketAddress(remoteHost, remotePort),
+ externalHost, localPort);
+ }
+ /**
+ * Boot into the Pastry Network
+ *
+ * @param remote
+ * the boot node
+ * @param externalAddress
+ * our external IP
+ * @param localPort
+ * the port we bind to
+ * @return The local PastryNode, that is connected in the Pastry Network
+ * @throws IOException
+ */
+ public static Node boot(InetSocketAddress remote,
+ InetAddress externalAddress, int localPort) throws IOException {
+ return boot(remote,externalAddress,localPort,null);
+ }
+
+
+ /**
+ * Boot into the Pastry Network
+ *
+ * @param remote
+ * the boot node
+ * @param externalAddress
+ * our external IP
+ * @param localPort
+ * the port we bind to
+ * @return The local PastryNode, that is connected in the Pastry Network
+ * @throws IOException
+ */
+ public static Node boot(InetSocketAddress remote,
+ InetAddress externalAddress, int localPort, LogManager logManager) throws IOException {
+ PastryNode node;
+
+ Environment environment = new Environment(null, null, null,
+ NTPTimeSource.getTimeSource(), logManager, new SimpleParameters(
+ new String[]{"mmog"}, null), null);
+ NodeIdFactory nidFactory = new RandomNodeIdFactory(environment);
+ SocketPastryNodeFactory factory = new SocketPastryNodeFactory(
+ nidFactory, externalAddress, localPort, environment, null);
+
+ node = factory.newNode(factory.getNodeHandle(remote));
+
+ while (!node.isReady()) {
+ // delay so we don't busy-wait
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ }
+ }
+
+ return node;
+ }
+}
Copied: trunk/P2PlayBoot/src/org/p2play/boot/pastry/time (from rev 28, trunk/P2PlayBoot/src/org/p2play/net/pastry/time)
Deleted: trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/NTPMessage.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/net/pastry/time/NTPMessage.java 2007-01-22 12:50:57 UTC (rev 28)
+++ trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/NTPMessage.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -1,472 +0,0 @@
-package org.p2play.net.pastry.time;
-/*
- * Copyright (c) 2004, Adam Buckley
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of Adam Buckley nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Random;
-
-
-/**
- * This class represents a NTP message, as specified in RFC 2030. The message
- * format is compatible with all versions of NTP and SNTP.
- *
- * This class does not support the optional authentication protocol, and
- * ignores the key ID and message digest fields.
- *
- * For convenience, this class exposes message values as native Java types, not
- * the NTP-specified data formats. For example, timestamps are
- * stored as doubles (as opposed to the NTP unsigned 64-bit fixed point
- * format).
- *
- * However, the contructor NtpMessage(byte[]) and the method toByteArray()
- * allow the import and export of the raw NTP message format.
- *
- *
- * Usage example
- *
- * // Send message
- * DatagramSocket socket = new DatagramSocket();
- * InetAddress address = InetAddress.getByName("ntp.cais.rnp.br");
- * byte[] buf = new NtpMessage().toByteArray();
- * DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 123);
- * socket.send(packet);
- *
- * // Get response
- * socket.receive(packet);
- * System.out.println(msg.toString());
- *
- * Comments for member variables are taken from RFC2030 by David Mills,
- * University of Delaware.
- *
- * Number format conversion code in NtpMessage(byte[] array) and toByteArray()
- * inspired by http://www.pps.jussieu.fr/~jch/enseignement/reseaux/
- * NTPMessage.java which is copyright (c) 2003 by Juliusz Chroboczek
- *
- * @author Adam Buckley
- */
-public class NTPMessage {
- private static Random random=new Random();
-
- /**
- * This is a two-bit code warning of an impending leap second to be
- * inserted/deleted in the last minute of the current day. It's values
- * may be as follows:
- *
- * Value Meaning
- * ----- -------
- * 0 no warning
- * 1 last minute has 61 seconds
- * 2 last minute has 59 seconds)
- * 3 alarm condition (clock not synchronized)
- */
- public byte leapIndicator = 0;
-
-
- /**
- * This value indicates the NTP/SNTP version number. The version number
- * is 3 for Version 3 (IPv4 only) and 4 for Version 4 (IPv4, IPv6 and OSI).
- * If necessary to distinguish between IPv4, IPv6 and OSI, the
- * encapsulating context must be inspected.
- */
- public byte version = 3;
-
-
- /**
- * This value indicates the mode, with values defined as follows:
- *
- * Mode Meaning
- * ---- -------
- * 0 reserved
- * 1 symmetric active
- * 2 symmetric passive
- * 3 client
- * 4 server
- * 5 broadcast
- * 6 reserved for NTP control message
- * 7 reserved for private use
- *
- * In unicast and anycast modes, the client sets this field to 3 (client)
- * in the request and the server sets it to 4 (server) in the reply. In
- * multicast mode, the server sets this field to 5 (broadcast).
- */
- public byte mode = 0;
-
-
- /**
- * This value indicates the stratum level of the local clock, with values
- * defined as follows:
- *
- * Stratum Meaning
- * ----------------------------------------------
- * 0 unspecified or unavailable
- * 1 primary reference (e.g., radio clock)
- * 2-15 secondary reference (via NTP or SNTP)
- * 16-255 reserved
- */
- public short stratum = 0;
-
-
- /**
- * This value indicates the maximum interval between successive messages,
- * in seconds to the nearest power of two. The values that can appear in
- * this field presently range from 4 (16 s) to 14 (16284 s); however, most
- * applications use only the sub-range 6 (64 s) to 10 (1024 s).
- */
- public byte pollInterval = 0;
-
-
- /**
- * This value indicates the precision of the local clock, in seconds to
- * the nearest power of two. The values that normally appear in this field
- * range from -6 for mains-frequency clocks to -20 for microsecond clocks
- * found in some workstations.
- */
- public byte precision = 0;
-
-
- /**
- * This value indicates the total roundtrip delay to the primary reference
- * source, in seconds. Note that this variable can take on both positive
- * and negative values, depending on the relative time and frequency
- * offsets. The values that normally appear in this field range from
- * negative values of a few milliseconds to positive values of several
- * hundred milliseconds.
- */
- public double rootDelay = 0;
-
-
- /**
- * This value indicates the nominal error relative to the primary reference
- * source, in seconds. The values that normally appear in this field
- * range from 0 to several hundred milliseconds.
- */
- public double rootDispersion = 0;
-
-
- /**
- * This is a 4-byte array identifying the particular reference source.
- * In the case of NTP Version 3 or Version 4 stratum-0 (unspecified) or
- * stratum-1 (primary) servers, this is a four-character ASCII string, left
- * justified and zero padded to 32 bits. In NTP Version 3 secondary
- * servers, this is the 32-bit IPv4 address of the reference source. In NTP
- * Version 4 secondary servers, this is the low order 32 bits of the latest
- * transmit timestamp of the reference source. NTP primary (stratum 1)
- * servers should set this field to a code identifying the external
- * reference source according to the following list. If the external
- * reference is one of those listed, the associated code should be used.
- * Codes for sources not listed can be contrived as appropriate.
- *
- * Code External Reference Source
- * ---- -------------------------
- * LOCL uncalibrated local clock used as a primary reference for
- * a subnet without external means of synchronization
- * PPS atomic clock or other pulse-per-second source
- * individually calibrated to national standards
- * ACTS NIST dialup modem service
- * USNO USNO modem service
- * PTB PTB (Germany) modem service
- * TDF Allouis (France) Radio 164 kHz
- * DCF Mainflingen (Germany) Radio 77.5 kHz
- * MSF Rugby (UK) Radio 60 kHz
- * WWV Ft. Collins (US) Radio 2.5, 5, 10, 15, 20 MHz
- * WWVB Boulder (US) Radio 60 kHz
- * WWVH Kaui Hawaii (US) Radio 2.5, 5, 10, 15 MHz
- * CHU Ottawa (Canada) Radio 3330, 7335, 14670 kHz
- * LORC LORAN-C radionavigation system
- * OMEG OMEGA radionavigation system
- * GPS Global Positioning Service
- * GOES Geostationary Orbit Environment Satellite
- */
- public byte[] referenceIdentifier = {0, 0, 0, 0};
-
-
- /**
- * This is the time at which the local clock was last set or corrected, in
- * seconds since 00:00 1-Jan-1900.
- */
- public double referenceTimestamp = 0;
-
-
- /**
- * This is the time at which the request departed the client for the
- * server, in seconds since 00:00 1-Jan-1900.
- */
- public double originateTimestamp = 0;
-
-
- /**
- * This is the time at which the request arrived at the server, in seconds
- * since 00:00 1-Jan-1900.
- */
- public double receiveTimestamp = 0;
-
-
- /**
- * This is the time at which the reply departed the server for the client,
- * in seconds since 00:00 1-Jan-1900.
- */
- public double transmitTimestamp = 0;
-
-
-
- /**
- * Constructs a new NtpMessage from an array of bytes.
- */
- public NTPMessage(byte[] array) {
- // See the packet format diagram in RFC 2030 for details
- leapIndicator = (byte) ((array[0] >> 6) & 0x3);
- version = (byte) ((array[0] >> 3) & 0x7);
- mode = (byte) (array[0] & 0x7);
- stratum = unsignedByteToShort(array[1]);
- pollInterval = array[2];
- precision = array[3];
-
- rootDelay = (array[4] * 256.0) +
- unsignedByteToShort(array[5]) +
- (unsignedByteToShort(array[6]) / 256.0) +
- (unsignedByteToShort(array[7]) / 65536.0);
-
- rootDispersion = (unsignedByteToShort(array[8]) * 256.0) +
- unsignedByteToShort(array[9]) +
- (unsignedByteToShort(array[10]) / 256.0) +
- (unsignedByteToShort(array[11]) / 65536.0);
-
- referenceIdentifier[0] = array[12];
- referenceIdentifier[1] = array[13];
- referenceIdentifier[2] = array[14];
- referenceIdentifier[3] = array[15];
-
- referenceTimestamp = decodeTimestamp(array, 16);
- originateTimestamp = decodeTimestamp(array, 24);
- receiveTimestamp = decodeTimestamp(array, 32);
- transmitTimestamp = decodeTimestamp(array, 40);
- }
-
-
-
- /**
- * Constructs a new NtpMessage in client -> server mode, and sets the
- * transmit timestamp to the current time.
- */
- public NTPMessage() {
- // Note that all the other member variables are already set with
- // appropriate default values.
- this.mode = 3;
- this.transmitTimestamp = (System.currentTimeMillis()/1000.0) + 2208988800.0;
- }
-
-
-
- /**
- * This method constructs the data bytes of a raw NTP packet.
- */
- public byte[] toByteArray() {
- // All bytes are automatically set to 0
- byte[] p = new byte[48];
-
- p[0] = (byte) (leapIndicator << 6 | version << 3 | mode);
- p[1] = (byte) stratum;
- p[2] = pollInterval;
- p[3] = precision;
-
- // root delay is a signed 16.16-bit FP, in Java an int is 32-bits
- int l = (int) (rootDelay * 65536.0);
- p[4] = (byte) ((l >> 24) & 0xFF);
- p[5] = (byte) ((l >> 16) & 0xFF);
- p[6] = (byte) ((l >> 8) & 0xFF);
- p[7] = (byte) (l & 0xFF);
-
- // root dispersion is an unsigned 16.16-bit FP, in Java there are no
- // unsigned primitive types, so we use a long which is 64-bits
- long ul = (long) (rootDispersion * 65536.0);
- p[8] = (byte) ((ul >> 24) & 0xFF);
- p[9] = (byte) ((ul >> 16) & 0xFF);
- p[10] = (byte) ((ul >> 8) & 0xFF);
- p[11] = (byte) (ul & 0xFF);
-
- p[12] = referenceIdentifier[0];
- p[13] = referenceIdentifier[1];
- p[14] = referenceIdentifier[2];
- p[15] = referenceIdentifier[3];
-
- encodeTimestamp(p, 16, referenceTimestamp);
- encodeTimestamp(p, 24, originateTimestamp);
- encodeTimestamp(p, 32, receiveTimestamp);
- encodeTimestamp(p, 40, transmitTimestamp);
-
- return p;
- }
-
-
-
- /**
- * Returns a string representation of a NtpMessage
- */
- @Override
- public String toString() {
- String precisionStr = new DecimalFormat("0.#E0").format(Math.pow(2, precision));
-
- return "Leap indicator: " + leapIndicator + "\n" +
- "Version: " + version + "\n" +
- "Mode: " + mode + "\n" +
- "Stratum: " + stratum + "\n" +
- "Poll: " + pollInterval + "\n" +
- "Precision: " + precision + " (" + precisionStr + " seconds)\n" +
- "Root delay: " + new DecimalFormat("0.00").format(rootDelay*1000) + " ms\n" +
- "Root dispersion: " + new DecimalFormat("0.00").format(rootDispersion*1000) + " ms\n" +
- "Reference identifier: " + referenceIdentifierToString(referenceIdentifier, stratum, version) + "\n" +
- "Reference timestamp: " + timestampToString(referenceTimestamp) + "\n" +
- "Originate timestamp: " + timestampToString(originateTimestamp) + "\n" +
- "Receive timestamp: " + timestampToString(receiveTimestamp) + "\n" +
- "Transmit timestamp: " + timestampToString(transmitTimestamp);
- }
-
-
-
- /**
- * Converts an unsigned byte to a short. By default, Java assumes that
- * a byte is signed.
- */
- public static short unsignedByteToShort(byte b) {
- if((b & 0x80)==0x80) {
- return (short) (128 + (b & 0x7f));
- } else {
- return b;
- }
- }
-
-
-
- /**
- * Will read 8 bytes of a message beginning at <code>pointer</code>
- * and return it as a double, according to the NTP 64-bit timestamp
- * format.
- */
- public static double decodeTimestamp(byte[] array, int pointer) {
- double r = 0.0;
-
- for(int i=0; i<8; i++) {
- r += unsignedByteToShort(array[pointer+i]) * Math.pow(2, (3-i)*8);
- }
-
- return r;
- }
-
-
-
- /**
- * Encodes a timestamp in the specified position in the message
- */
- public static void encodeTimestamp(byte[] array, int pointer, double timestamp) {
- // Converts a double into a 64-bit fixed point
- for(int i=0; i<8; i++) {
- // 2^24, 2^16, 2^8, .. 2^-32
- double base = Math.pow(2, (3-i)*8);
-
- // Capture byte value
- array[pointer+i] = (byte) (timestamp / base);
-
- // Subtract captured value from remaining total
- timestamp -= (unsignedByteToShort(array[pointer+i]) * base);
- }
-
- // From RFC 2030: It is advisable to fill the non-significant
- // low order bits of the timestamp with a random, unbiased
- // bitstring, both to avoid systematic roundoff errors and as
- // a means of loop detection and replay detection.
- array[7+pointer] = (byte) (random.nextInt(255));
- }
-
-
-
- /**
- * Returns a timestamp (number of seconds since 00:00 1-Jan-1900) as a
- * formatted date/time string.
- */
- public static String timestampToString(double timestamp) {
- if(timestamp==0) {
- return "0";
- }
-
- // timestamp is relative to 1900, utc is used by Java and is relative
- // to 1970
- double utc = timestamp - (2208988800.0);
-
- // milliseconds
- long ms = (long) (utc * 1000.0);
-
- // date/time
- String date = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss").format(new Date(ms));
-
- // fraction
- double fraction = timestamp - ((long) timestamp);
- String fractionSting = new DecimalFormat(".000000").format(fraction);
-
- return date + fractionSting;
- }
-
-
-
- /**
- * Returns a string representation of a reference identifier according
- * to the rules set out in RFC 2030.
- */
- public static String referenceIdentifierToString(byte[] ref, short stratum, byte version) {
- // From the RFC 2030:
- // In the case of NTP Version 3 or Version 4 stratum-0 (unspecified)
- // or stratum-1 (primary) servers, this is a four-character ASCII
- // string, left justified and zero padded to 32 bits.
- if(stratum==0 || stratum==1) {
- return new String(ref);
- }
-
- // In NTP Version 3 secondary servers, this is the 32-bit IPv4
- // address of the reference source.
- else if(version==3) {
- return unsignedByteToShort(ref[0]) + "." +
- unsignedByteToShort(ref[1]) + "." +
- unsignedByteToShort(ref[2]) + "." +
- unsignedByteToShort(ref[3]);
- }
-
- // In NTP Version 4 secondary servers, this is the low order 32 bits
- // of the latest transmit timestamp of the reference source.
- else if(version==4) {
- return "" + ((unsignedByteToShort(ref[0]) / 256.0) +
- (unsignedByteToShort(ref[1]) / 65536.0) +
- (unsignedByteToShort(ref[2]) / 16777216.0) +
- (unsignedByteToShort(ref[3]) / 4294967296.0));
- }
-
- return "";
- }
-}
Deleted: trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/NTPTimeSource.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/net/pastry/time/NTPTimeSource.java 2007-01-22 12:50:57 UTC (rev 28)
+++ trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/NTPTimeSource.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -1,151 +0,0 @@
-/*
- * Copyright 2006 P2Play.org
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.p2play.net.pastry.time;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Collections;
-
-import rice.environment.time.TimeSource;
-
-public class NTPTimeSource implements TimeSource, Runnable {
-
- private static NTPTimeSource timeSource=new NTPTimeSource();
-
- private NTPTimeSource() {
- Thread t=new Thread(this);
- t.setPriority(Thread.MIN_PRIORITY);
- t.start();
- }
-
- private long currentOffset;
-
- /** difference between the unix epoch and jan 1 1900 (NTP uses that) */
- private final static double SECONDS_1900_TO_EPOCH = 2208988800.0;
- private final static int NTP_PORT = 123;
-
- private static final String[] NTP_SERVERS = {"ntp1.ptb.de"};
-
- /**
- * Query the ntp servers, returning the current time from first one we find
- *
- * @return milliseconds since january 1, 1970 (UTC)
- * @throws IllegalArgumentException if none of the servers are reachable
- */
- private static long calculateCurrentOffset(String serverNames[]) {
- if (serverNames == null) {
- throw new IllegalArgumentException("No NTP servers specified");
- }
- ArrayList<String> names = new ArrayList<String>(serverNames.length);
- for (String element : serverNames) {
- names.add(element);
- }
- Collections.shuffle(names);
- for (int i = 0; i < names.size(); i++) {
- long now = calculateCurrentOffset(names.get(i));
- if (now != Long.MIN_VALUE) {
- return now;
- }
- }
- throw new IllegalArgumentException("No reachable NTP servers specified");
- }
-
- /**
- * Query the given NTP server, returning the current internet time
- *
- * @return milliseconds since january 1, 1970 (UTC), or -1 on error
- */
- private static long calculateCurrentOffset(String serverName) {
- try {
- // Send request
- DatagramSocket socket = new DatagramSocket();
- InetAddress address = InetAddress.getByName(serverName);
- byte[] buf = new NTPMessage().toByteArray();
- DatagramPacket packet = new DatagramPacket(buf, buf.length, address, NTP_PORT);
-
- // Set the transmit timestamp *just* before sending the packet
- // ToDo: Does this actually improve performance or not?
- NTPMessage.encodeTimestamp(packet.getData(), 40,
- (System.currentTimeMillis()/1000.0)
- + SECONDS_1900_TO_EPOCH);
-
- socket.send(packet);
-
- // Get response
- packet = new DatagramPacket(buf, buf.length);
- socket.setSoTimeout(10*1000);
- try {
- socket.receive(packet);
- } catch (InterruptedIOException iie) {
- socket.close();
- return -1;
- }
-
- // Immediately record the incoming timestamp
- double destinationTimestamp = (System.currentTimeMillis()/1000.0) + SECONDS_1900_TO_EPOCH;
-
- // Process response
- NTPMessage msg = new NTPMessage(packet.getData());
- /*double roundTripDelay = (destinationTimestamp-msg.originateTimestamp) -
- (msg.receiveTimestamp-msg.transmitTimestamp);*/
- double localClockOffset = ((msg.receiveTimestamp - msg.originateTimestamp) +
- (msg.transmitTimestamp - destinationTimestamp)) / 2;
- socket.close();
-
- long rv = (long)(localClockOffset*1000);
- //System.out.println("host: " + address.getHostAddress() + " rtt: " + roundTripDelay + " offset: " + localClockOffset + " seconds");
- return rv;
- } catch (IOException ioe) {
- //ioe.printStackTrace();
- return Long.MIN_VALUE;
- }
- }
-
-
- public long currentTimeMillis() {
- return System.currentTimeMillis()+currentOffset;
- }
-
- public void run() {
- while(true){
- currentOffset=calculateCurrentOffset(NTP_SERVERS);
-
- //System.out.println("current offset: "+currentOffset);
-
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- public static NTPTimeSource getTimeSource() {
- return timeSource;
- }
-
- public void sleep(long delay) throws InterruptedException {
- Thread.sleep(delay);
- }
-
-}
Deleted: trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/TimeManager.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/net/pastry/time/TimeManager.java 2007-01-22 12:50:57 UTC (rev 28)
+++ trunk/P2PlayBoot/src/org/p2play/boot/pastry/time/TimeManager.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -1,53 +0,0 @@
-/*
- * Copyright 2006 P2Play.org
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.p2play.net.pastry.time;
-
-import rice.p2p.commonapi.Node;
-
-public class TimeManager {
- private static TimeManager timeManager;
-
- private Node node;
-
- private long baseTime=0;
-
- private TimeManager(Node node) {
- super();
- this.node = node;
- }
-
- public static TimeManager getTimeManager() {
- if(timeManager==null) {
- throw new IllegalStateException("No TimeManager created. You have to call TimeManager.create() once before using it.");
- }
- return timeManager;
- }
-
- public static TimeManager create(Node node){
- if(timeManager==null) {
- timeManager=new TimeManager(node);
- }
-
- return timeManager;
- }
-
- public long getGameTime(){
- return (baseTime+node.getEnvironment().getTimeSource().currentTimeMillis())/100L;
- }
-}
Copied: trunk/P2PlayBoot/src/org/p2play/boot/time (from rev 28, trunk/P2PlayBoot/src/org/p2play/net/pastry/time)
Modified: trunk/P2PlayBoot/src/org/p2play/boot/time/NTPMessage.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/net/pastry/time/NTPMessage.java 2007-01-22 12:50:57 UTC (rev 28)
+++ trunk/P2PlayBoot/src/org/p2play/boot/time/NTPMessage.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -1,4 +1,4 @@
-package org.p2play.net.pastry.time;
+package org.p2play.boot.time;
/*
* Copyright (c) 2004, Adam Buckley
* All rights reserved.
Modified: trunk/P2PlayBoot/src/org/p2play/boot/time/NTPTimeSource.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/net/pastry/time/NTPTimeSource.java 2007-01-22 12:50:57 UTC (rev 28)
+++ trunk/P2PlayBoot/src/org/p2play/boot/time/NTPTimeSource.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -16,7 +16,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.p2play.net.pastry.time;
+package org.p2play.boot.time;
import java.io.IOException;
import java.io.InterruptedIOException;
Deleted: trunk/P2PlayBoot/src/org/p2play/boot/time/TimeManager.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/net/pastry/time/TimeManager.java 2007-01-22 12:50:57 UTC (rev 28)
+++ trunk/P2PlayBoot/src/org/p2play/boot/time/TimeManager.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -1,53 +0,0 @@
-/*
- * Copyright 2006 P2Play.org
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.p2play.net.pastry.time;
-
-import rice.p2p.commonapi.Node;
-
-public class TimeManager {
- private static TimeManager timeManager;
-
- private Node node;
-
- private long baseTime=0;
-
- private TimeManager(Node node) {
- super();
- this.node = node;
- }
-
- public static TimeManager getTimeManager() {
- if(timeManager==null) {
- throw new IllegalStateException("No TimeManager created. You have to call TimeManager.create() once before using it.");
- }
- return timeManager;
- }
-
- public static TimeManager create(Node node){
- if(timeManager==null) {
- timeManager=new TimeManager(node);
- }
-
- return timeManager;
- }
-
- public long getGameTime(){
- return (baseTime+node.getEnvironment().getTimeSource().currentTimeMillis())/100L;
- }
-}
Modified: trunk/P2PlayBoot/src/org/p2play/boot/vfs/PastryFileProvider.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/boot/vfs/PastryFileProvider.java 2007-01-22 14:18:04 UTC (rev 32)
+++ trunk/P2PlayBoot/src/org/p2play/boot/vfs/PastryFileProvider.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -10,7 +10,7 @@
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
-import org.p2play.net.pastry.NodeHandler;
+import org.p2play.boot.pastry.NodeHandler;
public class PastryFileProvider extends AbstractOriginatingFileProvider {
Modified: trunk/P2PlayBoot/src/org/p2play/boot/vfs/PastryFileSystem.java
===================================================================
--- trunk/P2PlayBoot/src/org/p2play/boot/vfs/PastryFileSystem.java 2007-01-22 14:18:04 UTC (rev 32)
+++ trunk/P2PlayBoot/src/org/p2play/boot/vfs/PastryFileSystem.java 2007-01-22 14:25:22 UTC (rev 33)
@@ -6,7 +6,7 @@
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.provider.AbstractFileSystem;
-import org.p2play.net.pastry.NodeHandler;
+import org.p2play.boot.pastry.NodeHandler;
import rice.p2p.commonapi.Node;
import rice.p2p.past.Past;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ti...@us...> - 2007-01-22 14:18:05
|
Revision: 32
http://p2play.svn.sourceforge.net/p2play/?rev=32&view=rev
Author: tisoft
Date: 2007-01-22 06:18:04 -0800 (Mon, 22 Jan 2007)
Log Message:
-----------
added test server implementation from uni cvs
Added Paths:
-----------
trunk/P2Play/src/org/p2play/region/impl/ServerHandler.java
trunk/P2Play/src/org/p2play/region/impl/SingleStaticNetworkRegionManager.java
Added: trunk/P2Play/src/org/p2play/region/impl/ServerHandler.java
===================================================================
--- trunk/P2Play/src/org/p2play/region/impl/ServerHandler.java (rev 0)
+++ trunk/P2Play/src/org/p2play/region/impl/ServerHandler.java 2007-01-22 14:18:04 UTC (rev 32)
@@ -0,0 +1,154 @@
+package org.p2play.region.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.p2play.data.DataManager;
+import org.p2play.region.Client;
+import org.p2play.region.GameAction;
+import org.p2play.region.GameState;
+import org.p2play.region.Region;
+import org.p2play.region.RegionManager;
+import org.p2play.region.Server;
+import org.p2play.region.ServerFactory;
+import org.p2play.scripting.pnuts.object.GameStateObject;
+import org.p2play.util.ListMap;
+
+import rice.p2p.util.rawserialization.SimpleInputBuffer;
+import rice.p2p.util.rawserialization.SimpleOutputBuffer;
+
+public class ServerHandler implements Client {
+ private HashMap<Region, Server> serverMap;
+
+ private ServerFactory serverFactory;
+
+ private RegionManager regionManager;
+
+ private HashMap<Region, GameState> gameStateMap;
+
+ private ListMap<Region, GameAction> serverInteractionMap;
+
+ private Set<Region> serverSet;
+
+ public ServerHandler(RegionManager regionManager, DataManager dataManager,
+ ServerFactory serverFactory) {
+ super();
+ this.regionManager = regionManager;
+ this.serverFactory = serverFactory;
+ this.serverSet=new HashSet<Region>();
+
+ serverMap = new HashMap<Region, Server>();
+ gameStateMap = new HashMap<Region, GameState>();
+
+ serverInteractionMap = new ListMap<Region, GameAction>();
+ }
+
+ public void startServer(final Region region, final long gameTime) {
+ if (!serverSet.contains(region)) {
+ new Thread(new Runnable() {
+ public void run() {
+ Server server = serverMap.get(region);
+ if (server == null) {
+ server = serverFactory.getServer(region);
+
+ long randomSeed = 0;
+ try {
+ randomSeed = new DataInputStream(
+ new ByteArrayInputStream(
+
+ region.getRegionIdentifier().getBytes(
+ "UTF-8"))).readLong();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ GameState gameState = server.init(gameTime, randomSeed);
+ gameStateMap.put(region, gameState);
+
+ serverMap.put(region, server);
+
+ regionManager.joinRegion(region, ServerHandler.this);
+ }
+ }
+ }).start();
+ }
+
+ }
+
+ public Iterator<Region> iteratorOfRegions() {
+ return new HashSet<Region>(serverMap.keySet()).iterator();
+ }
+
+ public boolean hasServer(Region region) {
+ return serverMap.containsKey(region);
+ }
+
+ public boolean isIdle(Region region) {
+ return serverMap.get(region).isEmpty(getGameState(region));
+ }
+
+ public void handleGameStateChanged(Region region, GameState gameState) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void handleRegionChange(Region oldRegion, Region newRegion, Object gameObject) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void addGameAction(Region region, GameAction gameAction) {
+ serverInteractionMap.add(region, gameAction);
+ }
+
+ public int getHash(Region region) {
+ return getGameState(region).hash();
+ }
+
+ public GameState getGameState(Region region) {
+ return gameStateMap.get(region);
+ }
+
+ public void tick(Region region/* , long gameTime */) {
+ // TODO: tick to current
+
+ Server server = serverMap.get(region);
+ if (server != null) {
+ gameStateMap.put(region, server.tick(clone(gameStateMap.get(region)),
+ serverInteractionMap.remove(region)));
+
+ if (!isIdle(region)) {
+ // TODO: auch gefrickelt...
+ // join all neigbours
+ Iterator<Region> neighbouts = server
+ .getNeighbourRegionIdentifiers().iterator();
+ while (neighbouts.hasNext()) {
+ Region r = neighbouts.next();
+ regionManager.joinRegion(r, this);
+ }
+ }
+ }
+
+ }
+
+ private GameState clone(GameState state) {
+ GameState clone=null;
+
+ if (state instanceof GameStateObject) {
+ GameStateObject gso = (GameStateObject) state;
+ SimpleOutputBuffer buf=new SimpleOutputBuffer();
+ try{
+ gso.doSerialize(buf);
+ clone=new GameStateObject(new SimpleInputBuffer(buf.getBytes()));
+ }catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+
+ return clone;
+ }
+}
Added: trunk/P2Play/src/org/p2play/region/impl/SingleStaticNetworkRegionManager.java
===================================================================
--- trunk/P2Play/src/org/p2play/region/impl/SingleStaticNetworkRegionManager.java (rev 0)
+++ trunk/P2Play/src/org/p2play/region/impl/SingleStaticNetworkRegionManager.java 2007-01-22 14:18:04 UTC (rev 32)
@@ -0,0 +1,217 @@
+package org.p2play.region.impl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.p2play.data.DataManager;
+import org.p2play.io.Serializer;
+import org.p2play.net.pastry.time.TimeManager;
+import org.p2play.region.Client;
+import org.p2play.region.GameAction;
+import org.p2play.region.GameState;
+import org.p2play.region.Region;
+import org.p2play.region.RegionManager;
+import org.p2play.region.ServerFactory;
+import org.p2play.region.message.GameActionMessage;
+import org.p2play.region.message.GameStateMessage;
+import org.p2play.region.message.JoinMessage;
+import org.p2play.region.message.RegionMessage;
+import org.p2play.scripting.pnuts.api.region.RegionChangeGameAction;
+import org.p2play.util.ListMap;
+
+import rice.environment.time.TimeSource;
+import rice.p2p.commonapi.Node;
+import rice.p2p.scribe.Scribe;
+import rice.p2p.scribe.ScribeImpl;
+
+public final class SingleStaticNetworkRegionManager implements Runnable,
+ RegionManager {
+ private ListMap<Region, Client> clientMap;
+
+ private HashMap<Region, GameState> gameStateMap;
+
+ private List<GameAction> clientInteractionQueue;
+
+ private NetworkHandler networkHandler;
+
+ private static int tickGap = 100;
+
+ private TimeManager timeManager;
+
+ private ServerHandler serverHandler;
+
+ private TimeSource timeSource;
+
+ public SingleStaticNetworkRegionManager(Serializer serializer, Node node, DataManager dataManager,
+ ServerFactory serverFactory) {
+
+ timeManager = TimeManager.create(node);
+
+ timeSource=node.getEnvironment().getTimeSource();
+
+ clientMap = new ListMap<Region, Client>();
+ gameStateMap = new HashMap<Region, GameState>();
+
+ clientInteractionQueue = new LinkedList<GameAction>();
+
+ networkHandler = new NetworkHandler(serializer, this, node);
+
+ Scribe scribe = new ScribeImpl(node, "gamestate");
+ serverHandler = new ServerHandler(this, dataManager, serverFactory);
+
+ new Thread(this).start();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.upb.mmog.net.region.RegionManager#joinRegion(java.lang.String,
+ * de.upb.mmog.net.region.Client)
+ */
+ public void joinRegion(Region region, Client client) {
+ if (client != serverHandler)
+ System.out.println(client + " joins " + region);
+ synchronized (clientMap) {
+ clientMap.add(region, client);
+ networkHandler.joinRegion(region, timeManager.getGameTime());
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.upb.mmog.net.region.RegionManager#leaveRegion(java.lang.String,
+ * de.upb.mmog.net.region.Client)
+ */
+ public void leaveRegion(Region region, Client client) {
+ if (client != serverHandler)
+ System.out.println(client + " leaves " + region);
+ synchronized (clientMap) {
+ clientMap.remove(region, client);
+
+ if (clientMap.isEmpty(region)) {
+ // leave the region, if no server process is running on us
+ if (!serverHandler.hasServer(region)) {
+ networkHandler.leaveRegion(region);
+ }
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.upb.mmog.net.region.RegionManager#scheduleInteraction(de.upb.mmog.net.region.Client,
+ * de.upb.mmog.net.region.Interaction)
+ */
+ public void scheduleInteraction(Client client, GameAction interaction) {
+ synchronized (clientInteractionQueue) {
+ clientInteractionQueue.add(interaction);
+ }
+ }
+
+ /**
+ * 1. execute server processes 2. update client processes with new game
+ * state 3. send game state change requests
+ */
+ @SuppressWarnings("unchecked")
+ public void run() {
+ while (true) {
+ long time = timeSource.currentTimeMillis();
+ Iterator<Region> servers = serverHandler.iteratorOfRegions();
+ while (servers.hasNext()) {
+ Region server = servers.next();
+
+ serverHandler.tick(server);
+
+ // only send if not emoty
+ networkHandler
+ .sendGameState(serverHandler.getGameState(server));
+ }
+ // TODO: clear old requests
+
+ // Iterate over the regions
+ synchronized (clientMap) {
+ Iterator<Region> regions = clientMap.keySet().iterator();
+
+ while (regions.hasNext()) {
+ Region region = regions.next();
+
+ GameState gameState = gameStateMap.get(region);// remove(region);
+
+ // Iterate over the controllers
+ Iterator<Client> clients = clientMap.iterator(region);
+ while (clients.hasNext()) {
+ Client client = clients.next();
+ // update the client with the current game state
+ if (region != null && gameState != null) {
+ client.handleGameStateChanged(region, gameState);
+ }
+ }
+ }
+
+ }
+
+ synchronized (clientInteractionQueue) {
+ Iterator<GameAction> requests = clientInteractionQueue
+ .iterator();
+ while (requests.hasNext()) {
+ GameAction request = requests.next();
+
+ networkHandler.sendInteraction(request);
+ requests.remove();
+ }
+ }
+
+ try {
+
+ timeSource.sleep(Math.max(1, tickGap + time
+ - timeSource.currentTimeMillis()));
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public void handleMessageReceived(RegionMessage message) {
+ if (message instanceof GameActionMessage) {
+ GameActionMessage im = (GameActionMessage) message;
+
+ // TODO gefuckelt
+ synchronized (clientMap) {
+ if (im.getGameAction() instanceof RegionChangeGameAction) {
+ RegionChangeGameAction rcga = (RegionChangeGameAction) im
+ .getGameAction();
+ System.out.println("!!!Got Regionchange: "
+ + rcga.getSourceRegion() + "->" + rcga.getRegion());
+ System.out.println(clientMap);
+ if (!rcga.getSourceRegion().equals(rcga.getRegion())) {
+ Iterator<Client> iterator = clientMap.clonedIterator(rcga
+ .getSourceRegion());
+ while (iterator.hasNext()) {
+ Client client = iterator.next();
+
+ client.handleRegionChange(rcga.getSourceRegion(), rcga.getRegion(), rcga
+ .getGameObject());
+ }
+ }
+ }
+ }
+
+ serverHandler.addGameAction(im.getRegion(), im.getGameAction());
+ } else if (message instanceof GameStateMessage) {
+ GameStateMessage gsm = (GameStateMessage) message;
+
+ gameStateMap.put(gsm.getRegion(), gsm.getGameState());
+ } else if (message instanceof JoinMessage) {
+ JoinMessage jm = (JoinMessage) message;
+
+ serverHandler.startServer(jm.getRegion(), jm.getGameTime());
+ }// TODO: add handling of leave message
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|