[Neo-report] r1896 gregory - in /trunk/neo: handler.py protocol.py tests/__init__.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Mar 5 22:23:15 CET 2010


Author: gregory
Date: Fri Mar  5 22:23:15 2010
New Revision: 1896

Log:
Add 'Notify' packet.

General purpose packet to log a message on a remote peer.

Modified:
    trunk/neo/handler.py
    trunk/neo/protocol.py
    trunk/neo/tests/__init__.py

Modified: trunk/neo/handler.py
==============================================================================
--- trunk/neo/handler.py [iso-8859-1] (original)
+++ trunk/neo/handler.py [iso-8859-1] Fri Mar  5 22:23:15 2010
@@ -132,6 +132,9 @@
 
 
     # Packet handlers.
+
+    def notify(self, conn, message):
+        logging.info('notification from %s:%d: %s', *(conn.getAddress(), message))
 
     def requestIdentification(self, conn, node_type,
                                         uuid, address, name):

Modified: trunk/neo/protocol.py
==============================================================================
--- trunk/neo/protocol.py [iso-8859-1] (original)
+++ trunk/neo/protocol.py [iso-8859-1] Fri Mar  5 22:23:15 2010
@@ -303,13 +303,21 @@
     def getAnswerClass(self):
         return self._answer
 
+class Notify(Packet):
+    """
+        General purpose notification (remote logging)
+    """
+    def _encode(self, message):
+        return message
+
+    def _decode(self, body):
+        return (body, )
 
 class Ping(Packet):
     """
     Check if a peer is still alive. Any -> Any.
     """
     pass
-
 
 class Pong(Packet):
     """
@@ -1536,6 +1544,7 @@
 
     # packets registration
     Error = register(0x8000, Error)
+    Notify = register(0x0032, Notify)
     Ping, Pong = register(
             0x0001,
             Ping,

Modified: trunk/neo/tests/__init__.py
==============================================================================
--- trunk/neo/tests/__init__.py [iso-8859-1] (original)
+++ trunk/neo/tests/__init__.py [iso-8859-1] Fri Mar  5 22:23:15 2010
@@ -250,6 +250,9 @@
             return packet.decode()
         return packet
 
+    def checkNotify(self, conn, **kw):
+        return self.checkNotifyPacket(conn, Packets.Notify, **kw)
+
     def checkNotifyNodeInformation(self, conn, **kw):
         return self.checkNotifyPacket(conn, Packets.NotifyNodeInformation, **kw)
 





More information about the Neo-report mailing list