(Boeing r1764)

added Broker.handlerawmsg() helper to invoke handlemsg() using packed bytes
This commit is contained in:
ahrenholz 2013-09-04 17:03:34 +00:00
parent 83d238c691
commit 30965ba950
2 changed files with 9 additions and 4 deletions

View file

@ -779,6 +779,14 @@ class CoreBroker(ConfigurableManager):
self.session._handlerslock.release() self.session._handlerslock.release()
return host return host
def handlerawmsg(self, msg):
''' Helper to invoke handlemsg() using raw (packed) message bytes.
'''
hdr = msg[:coreapi.CoreMessage.hdrsiz]
msgtype, flags, msglen = coreapi.CoreMessage.unpackhdr(hdr)
msgcls = coreapi.msg_class(msgtype)
return self.handlemsg(msgcls(flags, hdr, msg[coreapi.CoreMessage.hdrsiz:]))
def forwardmsg(self, msg, serverlist, handle_locally): def forwardmsg(self, msg, serverlist, handle_locally):
''' Forward API message to all servers in serverlist; if an empty ''' Forward API message to all servers in serverlist; if an empty
host/port is encountered, set the handle_locally flag. Returns the host/port is encountered, set the handle_locally flag. Returns the

View file

@ -246,10 +246,7 @@ class Session(object):
except Exception, e: except Exception, e:
self.warn("Error sending Event Message: %s" % e) self.warn("Error sending Event Message: %s" % e)
# also inform slave servers # also inform slave servers
coremsg = coreapi.CoreEventMessage(0, tmp = self.broker.handlerawmsg(msg)
msg[:coreapi.CoreMessage.hdrsiz],
msg[coreapi.CoreMessage.hdrsiz:])
tmp = self.broker.handlemsg(coremsg)
return replies return replies