/*********************************************************************/
/* */
/* 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.Reflection;
using System.ServiceModel;
using AgentService.Platform;
namespace AgentService.Agent.Runtime
{
///
/// Class RemoteRuntime. Implements the interface IRuntimeEx and
/// exposes services to a remote client.
///
class RemoteRuntime : AgentService.Agent.Runtime.IRuntimeEx
{
///
/// Reference to the messaging service client.
///
private IMsgClient msg;
///
/// Messaging Service (Sends, retrieves messages and conversation management).
///
public IMsgClient MessageSvc
{
get
{
return this.msg;
}
}
///
/// Persistence service client.
///
private IPersistenceClient prs;
///
/// Persistence Service (Persists and resumes Knowledge objects).
///
public IPersistenceClient PersistenceSvc
{
get
{
return this.prs;
}
}
///
/// Logging Service Client
///
private ILogClient log;
///
/// Logging Service (Gives access to the agent logging subsystem).
///
public ILogClient LogSvc
{
get
{
return this.log;
}
}
///
/// Yellow Page service.
///
private IYellowPagesClient yPages;
///
/// Yellow Pages Service (Searches agent's aid by service).
///
public IYellowPagesClient YPageSvc
{
get
{
return this.yPages;
}
}
///
/// White Pages service.
///
private IWhitePagesClient wPages;
///
/// White Pages Service (Searches agent's aid by name).
///
public IWhitePagesClient WPageSvc
{
get
{
return this.wPages;
}
}
///
/// Mobility service.
///
private IMobilityClient mob;
///
/// Mobility Service (Move the agent to a remote platform)
///
public IMobilityClient MobilitySvc
{
get
{
return this.mob;
}
}
///
/// Platform console.
///
private ConsoleProxy console;
///
/// Gets a reference to the Platform Console.
///
public ConsoleProxy Console
{
get
{
return this.console;
}
}
///
/// Constructs a RemoteRuntime object with the given components.
///
/// The URI of the server
/// platform console
public RemoteRuntime(AgentService.Agent.IAgent agent, Uri server, ConsoleProxy platformConsole)
{/*
BasicHttpBinding binding = new BasicHttpBinding();
ChannelFactory msgFactory = new ChannelFactory(binding, new EndpointAddress(server));
ChannelFactory logFactory = new ChannelFactory(binding, new EndpointAddress(server));
ChannelFactory prsFactory = new ChannelFactory(binding, new EndpointAddress(server));
ChannelFactory ypFactory = new ChannelFactory(binding, new EndpointAddress(server));
ChannelFactory wpFactory = new ChannelFactory(binding, new EndpointAddress(server));
ChannelFactory mobFactory = new ChannelFactory(binding, new EndpointAddress(server));
this.msg = msgFactory.CreateChannel();
this.log = logFactory.CreateChannel();
this.prs = prsFactory.CreateChannel();
this.yPages = ypFactory.CreateChannel();
this.wPages = wpFactory.CreateChannel();
this.context = new DefaultBehaviourContext(agent);
this.console = platformConsole;
this.mob = mobFactory.CreateChannel();*/
}
///
/// Constructor used for cloning.
///
///
private RemoteRuntime()
{
// we do not have to do anything
// since all the fields will be
// set up in the Clone method
}
///
/// Gives a Runtime object for a new behaviour instance.
///
/// behaviour that will host the runtime
/// a Runtime object bound to the new behaviour
public IRuntime Clone(Behaviour.Behaviour behaviour)
{
RemoteRuntime cloned = new RemoteRuntime();
cloned.context = this.context.Clone(behaviour);
cloned.msg = this.msg;
cloned.prs = this.prs;
cloned.log = this.log;
cloned.yPages = this.yPages;
cloned.wPages = this.wPages;
cloned.console = this.console;
cloned.mob = this.mob;
return cloned;
}
///
/// Reference to the IBehaviourContext interface.
///
private DefaultBehaviourContext context;
///
/// Gets a reference to the IBehaviourContext interface.
///
public IBehaviourContext Context
{
get
{
return this.context;
}
}
}
}