Exemplo n.º 1
0
        /// <summary>  Applies <c>&lt;zone&gt;</c> elements to create new Zone instances.
        /// The caller is responsible for setting up topics, connecting to zones,
        /// and joining zones to topics.
        /// </summary>
        public virtual IZone [] ApplyZones(Agent agent)
        {
            IZoneFactory zf = agent.ZoneFactory;

            XmlElement [] zones = ZoneNodes;

            for (int i = 0; i < zones.Length; i++)
            {
                //  Get any properties defined for this zone. Zone properties
                //  should inherit from the agent's AgentProperties object, so
                //  pass that object as the parent
                AgentProperties props = new AgentProperties(agent.Properties);
                GetZoneProperties(props, zones[i]);

                string zoneId = zones[i].GetAttribute(XmlConstants.ID);
                if (zoneId.Trim().Length == 0)
                {
                    throw new AdkConfigException("<zone> cannot have an empty id attribute");
                }
                string zoneUrl = zones[i].GetAttribute(XmlConstants.URL);
                if (zoneUrl.Trim().Length == 0)
                {
                    throw new AdkConfigException("<zone> cannot have an empty url attribute");
                }

                //  Ask ZoneFactory to create a Zone instance
                zf.GetInstance(zoneId, zoneUrl, props);
            }

            return(agent.ZoneFactory.GetAllZones());
        }
Exemplo n.º 2
0
        protected override void InitBoard(IZoneFactory factory)
        {
            var zoneFactory = (ZoneFactory)factory;

            InitPlainWorld(zoneFactory.MakeGround);
            InitForest(zoneFactory.MakeForest);
            InitLava(zoneFactory.MakeLava);
        }
Exemplo n.º 3
0
        protected Board(int size, IZoneFactory factory)
        {
            _size  = size;
            _zones = new Zone[_size, _size];
            BoardMetadata.BoardSize = _size;

            InitBoard(factory);
        }
Exemplo n.º 4
0
        /// <summary>Constructor</summary>
        /// <param name="agentId">The string name that uniquely identifies this agent in SIF Zones.
        /// This string is used as the <c>SourceId</c> in all SIF message
        /// headers created by the agent.
        /// </param>
        public Agent(string agentId)
        {
            if (agentId == null || agentId.Trim().Length == 0)
            {
                AdkUtils._throw
                    (new ArgumentException("Agent ID cannot be null or a blank string"), Log);
            }

            fSourceId = agentId;

            ObjectFactory factory = ObjectFactory.GetInstance();

            fZoneFactory  = (IZoneFactory)factory.CreateInstance(ObjectFactory.ADKFactoryType.ZONE, this);
            fTopicFactory = (ITopicFactory)factory.CreateInstance(ObjectFactory.ADKFactoryType.TOPIC, this);

            fTransportManager = new TransportManagerImpl();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MudRealmFactory"/> class.
 /// </summary>
 /// <param name="zoneFactory">An IZoneFactory implementation required for setting up Realms.</param>
 public MudRealmFactory(IZoneFactory zoneFactory)
 {
     this.zoneFactory = zoneFactory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MudRealm"/> class.
 /// </summary>
 /// <param name="zoneFactory">The zone factory used to create new zones.</param>
 /// <param name="world">The world that owns this realm</param>
 public MudRealm(IZoneFactory zoneFactory, IWorld world) : this(zoneFactory)
 {
     this.Owner = world;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MudRealm"/> class.
 /// </summary>
 /// <param name="zoneFactory">The zone factory used to create new zones.</param>
 public MudRealm(IZoneFactory zoneFactory)
 {
     this.zoneFactory = zoneFactory;
     this.zones       = new List <IZone>();
 }
Exemplo n.º 8
0
 protected abstract void InitBoard(IZoneFactory factory);
Exemplo n.º 9
0
        public virtual void Shutdown(ProvisioningFlags provisioningOptions)
        {
            if (!fInit)
            {
                return;
            }

            fShutdownInProgress = true;
            if ((Adk.Debug & AdkDebugFlags.Lifecycle) != 0)
            {
                Log.Info("Shutting down agent...");
            }

            //	Close the SIFProfilerClient if supported
#if PROFILED
            {
                // TODO: Implement Support for Profiling
                com.OpenADK.sifprofiler.SIFProfilerClient prof =
                    com.OpenADK.sifprofiler.SIFProfilerClient.getInstance(ProfilerUtils.getProfilerName());
                if (prof != null)
                {
                    try
                    {
                        prof.close();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
#endif

            try
            {
                //  JAVA_TODO:  Unsubscribe, Unprovide topics

                //  Disconnect and shutdown each zone...
                IZoneFactory zf    = IZoneFactory;
                IZone[]      zones = zf.GetAllZones();
                for (int i = 0; i < zones.Length; i++)
                {
                    zones[i].Disconnect(provisioningOptions);
                    ((ZoneImpl)zones[i]).Shutdown();
                }

                if (fTransportManager != null)
                {
                    //  Shutdown transports
                    if ((Adk.Debug & AdkDebugFlags.Lifecycle) != 0)
                    {
                        Log.Info("Shutting down Transports...");
                    }
                    fTransportManager.Shutdown();
                }

                //  Close RequestCache
                try
                {
                    RequestCache rc = RequestCache.GetInstance(this);
                    if (rc != null)
                    {
                        rc.Close();
                    }
                }
                catch
                {
                    // Do nothing
                }

                if ((Adk.Debug & AdkDebugFlags.Lifecycle) != 0)
                {
                    Log.Debug("Agent shutdown complete");
                }
            }
            finally
            {
                fInit     = false;
                fShutdown = true;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MudRealmFactory"/> class.
 /// </summary>
 /// <param name="zoneFactory">An IZoneFactory implementation required for setting up Realms.</param>
 public MudRealmFactory(IZoneFactory zoneFactory)
 {
     this.zoneFactory = zoneFactory;
 }
Exemplo n.º 11
0
        /// <summary>Constructor</summary>
        /// <param name="agentId">The string name that uniquely identifies this agent in SIF Zones.
        /// This string is used as the <c>SourceId</c> in all SIF message
        /// headers created by the agent.
        /// </param>
        public Agent( string agentId )
        {
            if ( agentId == null || agentId.Trim().Length == 0 )
            {
                AdkUtils._throw
                    ( new ArgumentException( "Agent ID cannot be null or a blank string" ), Log );
            }

            fSourceId = agentId;

            ObjectFactory factory = ObjectFactory.GetInstance();
            fZoneFactory = (IZoneFactory) factory.CreateInstance( ObjectFactory.ADKFactoryType.ZONE, this );
            fTopicFactory = (ITopicFactory) factory.CreateInstance( ObjectFactory.ADKFactoryType.TOPIC, this );

            fTransportManager = new TransportManagerImpl();
        }