Commit 02af232f authored by Grégory Wisniewski's avatar Grégory Wisniewski

Add 'Notify' packet.

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

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1896 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 61dbc7b6
......@@ -133,6 +133,9 @@ class EventHandler(object):
# 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):
raise UnexpectedPacketError
......
......@@ -303,6 +303,15 @@ class Packet(object):
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):
"""
......@@ -310,7 +319,6 @@ class Ping(Packet):
"""
pass
class Pong(Packet):
"""
Notify being alive. Any -> Any.
......@@ -1536,6 +1544,7 @@ class PacketRegistry(dict):
# packets registration
Error = register(0x8000, Error)
Notify = register(0x0032, Notify)
Ping, Pong = register(
0x0001,
Ping,
......
......@@ -250,6 +250,9 @@ class NeoTestBase(unittest.TestCase):
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment