All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bdi.planlib.messaging.SendXMPPPlan Maven / Gradle / Ivy

Go to download

The Jadex applib BDI package contains ready to use functionalities for BDI agents mostly in form of modules called capabilities.

The newest version!
package jadex.bdi.planlib.messaging;

import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Message;

import jadex.bdiv3x.runtime.Plan;

/**
 *  Send an instant message.
 */
public class SendXMPPPlan extends Plan
{
	/**
	 * The body method is called on the
	 * instatiated plan instance from the scheduler.
	 */
	public void body()
	{
		// Account settings.
		IMAccount account = (IMAccount)getParameter("account").getValue();
		if(account==null)
			fail();
		
		// Message settings.
		String	content	= (String)getParameter("content").getValue();
		String[] receivers	= (String[])getParameterSet("receivers").getValues();
		
		try
		{
			XMPPConnection connection = new XMPPConnection("jabber.ccc.de");
			connection.connect();
			connection.login(account.getId(), account.getPassword());
			
			for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy