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

jadex.micro.tutorial.a1.ChatService Maven / Gradle / Ivy

The newest version!
package jadex.micro.tutorial.a1;

import java.text.SimpleDateFormat;
import java.util.Date;

import jadex.micro.MicroAgent;
import jadex.providedservice.annotation.Service;
import jadex.providedservice.annotation.ServiceComponent;

/**
 *  Chat service implementation.
 */
@Service
public class ChatService implements IChatService
{
	//-------- attributes --------
	
	/** The agent. */
	@ServiceComponent
	protected MicroAgent agent;

	/**
	 *  Receives a chat message.
	 *  @param sender The sender's name.
	 *  @param text The message text.
	 */
	public void message(final String sender, final String text)
	{
		System.out.println(agent.getId()+" received at "
			+new SimpleDateFormat("hh:mm:ss").format(new Date())+" from: "+sender+" message: "+text);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy