using System.Threading;
using AsterNET.Manager.Action;
using AsterNET.Manager.Response;
namespace AsterNET.Manager
{
///
/// A simple response handler that stores the received response in a ResponseHandlerResult for further processing.
///
public class ResponseHandler : IResponseHandler
{
private ManagerAction action;
private AutoResetEvent autoEvent;
private int hash;
private ManagerResponse response;
///
/// Creates a new .
///
///
///
public ResponseHandler(ManagerAction action, AutoResetEvent autoEvent)
{
response = null;
this.action = action;
this.autoEvent = autoEvent;
}
///
/// Gets the response.
///
public ManagerResponse Response
{
get { return this.response; }
}
///
/// Gets the action.
///
public ManagerAction Action
{
get { return this.action; }
}
///
/// Gets or sets the hash.
///
public int Hash
{
get { return hash; }
set { hash = value; }
}
///
/// Frees this instance.
///
public void Free()
{
autoEvent = null;
action = null;
response = null;
}
///
/// This method is called when a response is received.
///
/// the response received
public virtual void HandleResponse(ManagerResponse response)
{
this.response = response;
if (autoEvent != null)
this.autoEvent.Set();
}
}
}