using System;
using Server.MQ;
using Server.Module;
using Server.Data;
using Server.Pack;
using Server.Data.Module;
using GameData;
using System.Xml;
using System.Collections.Generic;

namespace Server
{
    /// <summary>
    /// 服务单元工厂
    /// </summary>
    public abstract class ServerUtilFactory
    {
        private IGlobalFactory GlobalMQFactory;

        /// <summary>
        /// 创建消息管理
        /// </summary>
        public virtual IGlobalFactory CreateGlobalMQFactory() {
            if (GlobalMQFactory == null)
                GlobalMQFactory = new GlobalMQ.Factory();
            return GlobalMQFactory;
        }
        

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public abstract GlobalManager GetGlobalManager();

        /// <summary>
        /// 创建一些信息使用
        /// </summary>
        /// <param name="ObjectName"></param>
        /// <returns></returns>
        public abstract Object Produce(string ObjectName);

        /// <summary>
        /// 创建心跳包
        /// </summary>
        /// <returns></returns>
        public virtual string CreateHeartPack(ModuleUtile util) {
            PackHead head = PackHead.Create();
            head.sendutil = util;
            head.packlx = ServerPackAgreement.nodeHeart;
            string result = JsonPack.GetJsonByPack(head, null);
            head.Dispose();
            return result;
        }
        
        /// <summary>
        /// 创建消息处理器
        /// </summary>
        /// <returns></returns>
        public virtual GlobalManager.MessageProcessor CreateMessageProcessor() {
            return new GlobalManager.MessageProcessor();
        }

    }
}
