コード例 #1
0
ファイル: server.py プロジェクト: ciappi/Yaranullin
 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)
コード例 #2
0
ファイル: event_system.py プロジェクト: ciappi/Yaranullin
 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())
コード例 #3
0
ファイル: event_system.py プロジェクト: ciappi/Yaranullin
 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())
コード例 #4
0
ファイル: event_system.py プロジェクト: ciappi/Yaranullin
 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'])
コード例 #5
0
ファイル: event_system.py プロジェクト: ciappi/Yaranullin
 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'])
コード例 #6
0
ファイル: pipe.py プロジェクト: ciappi/Yaranullin
 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)
コード例 #7
0
ファイル: client.py プロジェクト: ciappi/Yaranullin
 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)
コード例 #8
0
ファイル: cache.py プロジェクト: ciappi/Yaranullin
                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)
コード例 #9
0
ファイル: base.py プロジェクト: ciappi/Yaranullin
 def __init__(self, sock=None, sockets=None):
     _EndPoint.__init__(self, sock, sockets)
     connect('tick', self.process_queue)
コード例 #10
0
ファイル: tmx_wrapper.py プロジェクト: ciappi/Yaranullin
 def __init__(self):
     self._maps = {}
     connect('game-event-pawn-moved', self.move_pawn)
コード例 #11
0
ファイル: game_wrapper.py プロジェクト: ciappi/Yaranullin
 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")
コード例 #12
0
ファイル: game_wrapper.py プロジェクト: ciappi/Yaranullin
 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)