/*********************************************************************/
/* */
/* AgentService Framework */
/* www.agentservice.it */
/* */
/* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */
/* GNU Lesser General Public License */
/* */
/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Lesser General Public */
/* License as published by the Free Software Foundation, */
/* version 2.1 of the License. */
/* */
/* This library is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* Lesser General Public License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public */
/* License along with this library; if not, write to the */
/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */
/* Boston, MA 02111-1307, USA. */
/* */
/*********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using AgentService.Platform.Modules;
namespace AgentService.Platform
{
public interface IEventManager
{
#region Standard Platform Events
///
/// Fires every time an agent is created.
///
event PlatformEventHandler OnAgentCreated;
///
/// Fires every time an agent is resumed.
///
event PlatformEventHandler OnAgentResumed;
///
/// Fires every time an agent is stopped.
///
event PlatformEventHandler OnAgentStopped;
///
/// Fires every time an agent is woken up.
///
event PlatformEventHandler OnAgentWokenUp;
///
/// Fires every time a message is sent.
///
event PlatformEventHandler OnMessageSent;
///
/// Fires every time a message is sent.
///
event PlatformEventHandler OnMessageReceived;
///
/// Fires every time a bulk of messages is received.
///
event PlatformEventHandler OnMessageBatch;
///
/// Fires every time a conversation is requested.
///
event PlatformEventHandler OnConversationRequested;
///
/// Fires every time a conversation is accepted and then opened.
///
event PlatformEventHandler OnConversationAccepted;
///
/// Fires every time a comversation is refused.
///
event PlatformEventHandler OnConversationRefused;
///
/// Fires every time a conversation is closed.
///
event PlatformEventHandler OnConversationClosed;
///
/// Fires every time an agent is persisted.
///
event PlatformEventHandler OnAgentPersisted;
///
/// Fires every time an assembly is uploaded into the platform storage.
///
event PlatformEventHandler OnAssemblyUploaded;
///
/// Fires every time an assembly is removed from the platform storage.
///
event PlatformEventHandler OnAssemblyRemoved;
#endregion
#region Standard Event Management
///
/// Fires a specified PlatformEvent, with the given args,
/// used by the platform in order to notify the modules that
/// have been registered for that event
///
/// type of the event
/// corresponding srguments
/// owning token
void RaiseStandardEvent(PlatformEvent eventType, PlatformEventArgs args, int token);
///
/// Retrieves a valid token for the given core module.
/// The token is used to allow core modules to raise
/// the standard events that belongs to them.
///
/// the instance of the module
/// which is requesting the token
/// owning token
int GetToken(IPlatformModule module);
#endregion
#region Custom Events Management
///
/// Adds an event to the custom event registry
///
/// name of the event
/// a token that is used by the owner to track the event, 0 if the event is already present
int AddEvent(string evtName);
///
/// Removes the event associated to the given token
///
/// token that identifies the event
bool RemoveEvent(int token);
///
/// Raises the event associated to the given token
///
/// token that identifies the event
/// event argument
/// true if the event is found
bool RaiseEvent(int token, PlatformEventArgs args);
///
/// Registers an handler to the given event
///
/// name that identifies the event
/// delegate the will be registered
/// true if the registration process is successful, false if the event is not present
bool Register(string evtName, PlatformEventHandler handler);
///
/// Deregisters an handler to the given event
///
/// name that identifies the event
/// delegate to deregister
/// true if the deregistration process succeeds, falise if the event is not present
bool Deregister(string evtName, PlatformEventHandler handler);
#endregion
}
}