Skip to content
Permalink
Browse files

- Fixed bug comparing JIDs in trace _agent_in_msg function.

- Imports optimized.
- Added new example.
  • Loading branch information...
javipalanca committed Sep 17, 2019
1 parent 902ab52 commit e2104083555a84034f49c79c6d5a3ab6e60cddfe
@@ -0,0 +1,45 @@
import asyncio
import getpass
import time

from spade.agent import Agent
from spade.behaviour import CyclicBehaviour


class DummyAgent(Agent):
class MyBehav(CyclicBehaviour):
async def on_start(self):
print("Starting behaviour . . .")
self.counter = 0

async def run(self):
print("Counter: {}".format(self.counter))
self.counter += 1
if self.counter > 3:
self.kill(exit_code=10)
return
await asyncio.sleep(1)

async def on_end(self):
print("Behaviour finished with exit code {}.".format(self.exit_code))

async def setup(self):
print("Agent starting . . .")
self.my_behav = self.MyBehav()
self.add_behaviour(self.my_behav)


if __name__ == "__main__":
jid1 = input("Agent JID> ")
passwd1 = getpass.getpass()
dummy = DummyAgent(jid1, passwd1)
future = dummy.start()
future.result() # Wait until the start method is finished

# wait until user interrupts with ctrl+C
while not dummy.my_behav.is_killed():
try:
time.sleep(1)
except KeyboardInterrupt:
break
dummy.stop()
@@ -1,9 +1,9 @@
import asyncio
import getpass

from spade import quit_spade
from spade.agent import Agent
from spade.behaviour import OneShotBehaviour
from spade import quit_spade


class DummyAgent(Agent):
@@ -2,10 +2,10 @@
import time
from sys import getsizeof

from spade import quit_spade
from spade.agent import Agent
from spade.behaviour import OneShotBehaviour
from spade.message import Message
from spade import quit_spade


class RecvBehav(OneShotBehaviour):
@@ -1,9 +1,10 @@
import time
import getpass
import time

from spade import quit_spade
from spade.agent import Agent
from spade.behaviour import OneShotBehaviour
from spade import quit_spade


class Agent1(Agent):
async def setup(self):
@@ -1,10 +1,11 @@
import time
import getpass
import time

from spade import quit_spade
from spade.agent import Agent
from spade.behaviour import OneShotBehaviour
from spade.message import Message
from spade.template import Template
from spade import quit_spade


class SenderAgent(Agent):
@@ -2,17 +2,16 @@
import asyncio
import datetime
import random
import click
import time

import aioxmpp
import click
from aioxmpp import PresenceType, Presence, JID, PresenceShow, MessageType
from aioxmpp.roster.xso import Item
import time
from spade.message import Message

from spade.behaviour import State

from spade import agent, behaviour
from spade.behaviour import State
from spade.message import Message
from spade.template import Template


@@ -1,11 +1,10 @@
import asyncio
import logging

import aiosasl
import sys
import asyncio
from hashlib import md5
from threading import Event

import aiosasl
import aioxmpp
import aioxmpp.ibr as ibr
from aioxmpp.dispatcher import SimpleMessageDispatcher
@@ -1,13 +1,12 @@
import asyncio
import collections
import logging
import time
import traceback
from abc import ABCMeta, abstractmethod
from asyncio import CancelledError
from threading import Event
from datetime import timedelta, datetime
import time

import asyncio
from threading import Event
from typing import Any, Union

from .message import Message
@@ -6,7 +6,7 @@


def _agent_in_msg(agent, msg):
return msg.to == agent or msg.sender == agent
return msg.to.bare() == agent or msg.sender.bare() == agent


class TraceStore(object):
@@ -2,11 +2,12 @@
import logging
import socket

import timeago
from aiohttp import web as aioweb
import aiohttp_jinja2
import jinja2
import timeago
from aiohttp import web as aioweb
from aioxmpp import PresenceType, JID

from spade.message import Message

logger = logging.getLogger("spade.Web")

0 comments on commit e210408

Please sign in to comment.
You can’t perform that action at this time.