Author: nextgens
Date: 2008-07-03 07:36:32 +0000 (Thu, 03 Jul 2008)
New Revision: 20952

Added:
   trunk/freenet/src/freenet/node/fcp/SubscribedUSKMessage.java
Modified:
   trunk/freenet/src/freenet/node/fcp/SubscribeUSKMessage.java
Log:
implement bug  #2443: Acknowledge SubscribeUSK

Modified: trunk/freenet/src/freenet/node/fcp/SubscribeUSKMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/SubscribeUSKMessage.java 2008-07-03 
07:08:52 UTC (rev 20951)
+++ trunk/freenet/src/freenet/node/fcp/SubscribeUSKMessage.java 2008-07-03 
07:36:32 UTC (rev 20952)
@@ -12,8 +12,9 @@
 import freenet.support.SimpleFieldSet;

 /**
- * Sent by a client to subscribe to a USK. The client will then be notified 
whenever a new latest version of
- * the USK is available. There is a flag for whether the node should actively 
probe for the USK.
+ * Sent by a client to subscribe to a USK. The client will then be notified by 
a SubscribedUSKMessage that his
+ * request has been taken into account and whenever a new latest version of 
the USK is available.
+ * There is a flag for whether the node should actively probe for the USK.
  * 
  * SubscribeUSK
  * URI=USK at 
60I8H8HinpgZSOuTSD66AVlIFAy-xsppFr0YCzCar7c,NzdivUGCGOdlgngOGRbbKDNfSCnjI0FXjHLzJM4xkJ4,AQABAAE/index/4
@@ -60,6 +61,9 @@
        public void run(FCPConnectionHandler handler, Node node)
                        throws MessageInvalidException {
                new SubscribeUSK(this, node.clientCore, handler);
+               
+               SubscribedUSKMessage reply = new SubscribedUSKMessage(this);
+               handler.outputHandler.queue(reply);
        }

 }

Added: trunk/freenet/src/freenet/node/fcp/SubscribedUSKMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/SubscribedUSKMessage.java                
                (rev 0)
+++ trunk/freenet/src/freenet/node/fcp/SubscribedUSKMessage.java        
2008-07-03 07:36:32 UTC (rev 20952)
@@ -0,0 +1,45 @@
+/* This code is part of Freenet. It is distributed under the GNU General
+ * Public License, version 2 (or at your option any later version). See
+ * http://www.gnu.org/ for further details of the GPL. */
+package freenet.node.fcp;
+
+import freenet.node.Node;
+import freenet.support.SimpleFieldSet;
+
+/**
+ * Sent by the node back to the client after it receives a SubscribeUSK 
message.
+ * 
+ * SubscribedUSK
+ * URI=USK at 
60I8H8HinpgZSOuTSD66AVlIFAy-xsppFr0YCzCar7c,NzdivUGCGOdlgngOGRbbKDNfSCnjI0FXjHLzJM4xkJ4,AQABAAE/index/4
+ * DontPoll=true // meaning passively subscribe, don't cause the node to 
actively probe for it
+ * Identifier=identifier
+ * End
+ * 
+ * @author Florent Daignière <nextgens at freenetproject.org>
+ */
+public class SubscribedUSKMessage extends FCPMessage {
+       public static final String name = "SubscribedUSK";
+       
+       public final SubscribeUSKMessage message;
+       
+       SubscribedUSKMessage(SubscribeUSKMessage m) {
+               this.message = m;
+       }
+       
+       public SimpleFieldSet getFieldSet() {
+               SimpleFieldSet sfs = new SimpleFieldSet(true);
+               sfs.putSingle("Identifier", message.identifier);
+               sfs.putSingle("URI", message.key.getURI().toString());
+               sfs.put("DontPoll", message.dontPoll);
+               
+               return sfs;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void run(FCPConnectionHandler handler, Node node) throws 
MessageInvalidException {
+               throw new 
MessageInvalidException(ProtocolErrorMessage.INVALID_MESSAGE, name + " goes 
from server to client not the other way around", name, false);
+       }
+}
\ No newline at end of file


Reply via email to