Exemplo n.º 1
0
 def __init__(self, sock):
     EndPoint.__init__(self, sock)
     connect('game-event-update', self.post)
     connect('game-event-pawn-next', self.post)
     connect('game-event-pawn-updated', self.post)
     connect('game-event-board-change', self.post)
     connect('resource-update', self.post)
Exemplo n.º 2
0
 def test_process_queue(self):
     connect('test', func_handler)
     event_dict = {'args1': 1, 'arg2':2}
     post('test', **event_dict)
     post('test', event_dict)
     process_queue()
     self.failUnlessEqual(event_dict, Q.popleft())
     self.failUnlessEqual(event_dict, Q.popleft())
Exemplo n.º 3
0
 def test_post(self):
     # Post a single event
     connect('test', func_handler)
     event_dict = {'event': 'test', 'id': post('test')}
     self.failUnlessEqual(event_dict, _QUEUE.popleft())
Exemplo n.º 4
0
 def test_disconnect(self):
     # Disconnect a single handler
     connect('test', func_handler)
     disconnect('test', func_handler)
     wrapper = WeakCallback(func_handler)
     self.assertFalse(wrapper in _EVENTS['test'])
Exemplo n.º 5
0
 def test_connect(self):
     # Connect a single handler
     connect('test', func_handler)
     wrapper = WeakCallback(func_handler)
     self.assertTrue('test' in _EVENTS)
     self.assertTrue(wrapper in _EVENTS['test'])
Exemplo n.º 6
0
 def __init__(self, in_queue, out_queue):
     self.in_queue = in_queue
     self.out_queue = out_queue
     self.posted_events = set()
     connect('any', self.handle)
     connect('tick', self.tick)
Exemplo n.º 7
0
 def __init__(self):
     EndPoint.__init__(self)
     connect('join', self.join)
     # Connect the events to send to the sever
     connect('game-request-pawn-move', self.post)
     connect('game-request-pawn-place', self.post)
     connect('game-request-pawn-next', self.post)
     connect('game-request-update', self.post)
     connect('resource-request', self.post)
Exemplo n.º 8
0
                tuple(kargs.items())]
        except KeyError:
            try:
                cached_obj = loader(resource_name, *args, **kargs)
            except IOError as why:
                if why.errno == 2:
                    # There is a missing file, ask the server...
                    post('resource-request', name=resource_name)
                else:
                    raise
            else:
                _CACHE[hash(loader), resource_name, args,
                    tuple(kargs.items())] = cached_obj
                return cached_obj

    return _cache


def update_cache(event_dict):
    ''' Update the cache '''
    resource_name = event_dict['name']
    resource = event_dict['resource']
    with open(os.path.join(YR_CACHE_DIR, resource_name), 'w') as file_:
        file_.write(resource)

#
# As soon as this module is imported, 'update_cache' is connected to
# the 'resource-update' event.
#
connect('resource-update', update_cache)
Exemplo n.º 9
0
 def __init__(self, sock=None, sockets=None):
     _EndPoint.__init__(self, sock, sockets)
     connect('tick', self.process_queue)
Exemplo n.º 10
0
 def __init__(self):
     self._maps = {}
     connect('game-event-pawn-moved', self.move_pawn)
Exemplo n.º 11
0
 def __init__(self):
     self.game = Game()
     self.tmx_wrapper = TmxWrapper()
     connect('game-request-board-new', self.create_board)
     connect('game-request-board-del', self.del_board)
     connect('game-request-pawn-new', self.create_pawn)
     connect('game-request-pawn-move', self.move_pawn)
     connect('game-request-pawn-del', self.del_pawn)
     connect('game-request-update', self.request_update)
     LOGGER.debug("GameWrapper initialized")
Exemplo n.º 12
0
 def __init__(self):
     self.boards = set()
     self.tmx_wrapper = TmxWrapper()
     connect('game-event-update', self.update)
     connect('game-request-board-new', self.create_board)
     connect('game-request-board-del', self.del_board)
     connect('game-request-pawn-new', self.create_pawn)
     connect('game-request-pawn-move', self.move_pawn)
     connect('game-request-pawn-del', self.del_pawn)