[P2play-commit] SF.net SVN: p2play: [36] trunk/P2Play
Status: Pre-Alpha
Brought to you by:
tisoft
|
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.
|