How to use the pelita.messaging.expose function in pelita

To help you get started, we’ve selected a few pelita examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ASPP / pelita / demo / messaging / demo_ping_pong.py View on Github external
    @expose
    def Ping(self):
        if self.pong_count % 100 == 0:
            delta = datetime.now() - self.old_time
            self.old_time = datetime.now()
            print "Pong: ping " + str(self.pong_count) + " from " + str(self.ref.channel) + \
                    str(delta.seconds) + "." + str(delta.microseconds // 1000)

        self.ref.channel.notify("Pong", channel=self.ref)
        self.pong_count += 1
github ASPP / pelita / test / test_actor.py View on Github external
    @expose
    def get_docstring(self, message):
        """ This method has no content but a docstring. """
github ASPP / pelita / demo / messaging / demo_server.py View on Github external
    @expose
    def multiply(self, *args):
        """Multiplies the argument list."""
        res = reduce(lambda x,y: x*y, args)
        print "Calculated", res
        self.ref.reply(res)
github ASPP / pelita / pelita / actors.py View on Github external
    @expose
    def is_server_connected(self):
        if isinstance(self.server_actor, RemoteActorReference):
            self.ref.reply(self.server_actor.is_connected())
        else:
            self.ref.reply(self.server_actor.is_alive)
github ASPP / pelita / pelita / actors.py View on Github external
    @expose
    def say_hello(self, main_actor, team_name, host=None, port=None):
        """ Opens a connection to the remote main_actor,
        and sends it a "hello" message with the given team_name.
        """

        self.server_actor = get_server_actor(main_actor, host, port)
        if not self.server_actor:
            self.ref.reply("failed")
            return

        try:
            if self.server_actor.query("hello", [team_name, self.ref.uuid]).get(2) == "ok":
                _logger.info("Connection accepted")
                self.ref.reply("ok")
        except Queue.Empty:
            self.ref.reply("actor no reply")
github ASPP / pelita / demo / messaging / demo_server.py View on Github external
    @expose
    def minigame(self):
        """Demos a small game."""
        if len(self.players) != 2:
            self.ref.reply("Need two players.")
            return

        reqs = []

        for player in self.players:
            reqs.append( player.query("random_int", []) )

        res = 0
        for answer in reqs:
            res += answer.get()

        if res % 2 != 0:
github ASPP / pelita / pelita / actors.py View on Github external
    @expose
    def delayed_start_game(self):
        """ Waits a bit before really starting the game. """
        time.sleep(0.3)
        self.ref.notify("start_game")
github ASPP / pelita / pelita / actors.py View on Github external
    @expose
    def initialize_game(self, layout, number_bots, game_time):
        """ Initialises a new game.
        """
        self.game_master = GameMaster(layout, number_bots, game_time)
        self.check_for_start()
github ASPP / pelita / demo / messaging / demo_ping_pong.py View on Github external
    @expose
    def Start(self):
        print "Ping: Starting"
        self.pong.notify("Ping", channel=self.ref)
        self.pings_left -= 1
github ASPP / pelita / pelita / actors.py View on Github external
    @expose
    def set_initial(self, universe):
        """ Called by the server. This method tells us the initial universe.
        """
        self.ref.reply(self.team._set_initial(universe))