Commit 24d1471a authored by Vincent Pelletier's avatar Vincent Pelletier

Make client asynchronous base handler only attemp to dispatch response...

Make client asynchronous base handler only attemp to dispatch response packets, and raise if it is not an expected response.
Add a method on Packet class to determine if it's a response.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@808 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent eeaa93d9
......@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo.handler import EventHandler
from neo.protocol import UnexpectedPacketError
class BaseHandler(EventHandler):
"""Base class for client-side EventHandler implementations."""
......@@ -37,11 +38,13 @@ class BaseHandler(EventHandler):
def packetReceived(self, conn, packet):
"""Redirect all received packet to dispatcher thread."""
if packet.isReponse():
queue = self.dispatcher.getQueue(conn, packet)
if queue is None:
self.dispatch(conn, packet)
else:
raise UnexpectedPacketError('Unexpected response packet')
queue.put((conn, packet))
else:
self.dispatch(conn, packet)
def _notifyQueues(self, conn):
"""
......
......@@ -448,6 +448,9 @@ class Packet(object):
raise PacketMalformedError('unknown message type 0x%x' % self._type)
return method(self._body)
def isResponse(self):
return self._type & 0x8000 == 0x8000
# packet parser
def parse(msg):
# logging.debug('parsing %s', dump(msg))
......
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