예제 #1
0
 def process_message(self, message, sock):
     logging.info('Received %s', message['data'])
     try:
         obj = util.parse(message['data'])
     except:
         logging.error('Message parsing failed')
         return
     # Convert serialized ref objects to callable references
     serializer.unserialize(self.bridge, obj['args'])
     # Extract RPC destination address
     destination = obj.get('destination', None)
     if not destination:
         logging.warning('No destination in message %s', obj)
         return
     if 'source' in message:
         self.bridge._context = client.Client(message['source'])
     self.bridge._execute(destination['ref'], obj['args'])
예제 #2
0
 def process_message(self, message, sock):
     logging.info('Received %s', message['data'])
     try:
         obj = util.parse(message['data'])
     except:
         logging.error('Message parsing failed')
         return
     # Convert serialized ref objects to callable references
     serializer.unserialize(self.bridge, obj['args'])
     # Extract RPC destination address
     destination = obj.get('destination', None)
     if not destination:
         logging.warning('No destination in message %s', obj)
         return
     if 'source' in message:
         self.bridge._context = client.Client(message['source'])
     self.bridge._execute(destination['ref'], obj['args'])
예제 #3
0
    def test_unserialize(self):
        dummy = BridgeDummy()
        obj = { 'a': {'ref': ['x','x','x'], 'operations': ['a','b']},
                'b': {'i': {'ref': ['z','z','z'], 'operations': ['callback']}},
                'c': 5,
                'd': True,
                'e': 'abc',
                'f': [1, {'ref': ['y','y','y'], 'operations': ['c','d']}],
                'g': 2,
                'h': 'foo' }
        unser = serializer.unserialize(dummy, obj)

        self.assertIsInstance(unser['a'], reference.Reference)
        self.assertIsInstance(unser['f'][1], reference.Reference)

        # Is a lambda, not a callbackreference.
        # self.assertIsInstance(unser['b']['i'], CallbackReference)
        return