private static void ReadConfig()
 {
     ServerModuleInfos.Clear();
     using (StreamReader stream = new StreamReader(ConfigPath))
     {
         string line;
         while ((line = stream.ReadLine()) != null)
         {
             ServerModuleInfo info  = new ServerModuleInfo();
             string[]         infos = line.Split('|');
             info.ID           = int.Parse(infos[0]);
             info.Port         = int.Parse(infos[1]);
             info.Name         = infos[2];
             info.AssemblyName = infos[3];
             ServerModuleInfos.Add(info.ID, info);
         }
     }
 }
Esempio n. 2
0
        public void StartServerModule(int id)
        {
            ServerModuleInfo info     = ServerModuleConfig.GetServerModuleInfo(id);
            string           fullName = nameSpace + "." + info.Name + "." + info.Name;

            try
            {
                Type type = Type.GetType(fullName + "," + info.AssemblyName);
                if (type != null)
                {
                    var module = Activator.CreateInstance(type) as ServerModule;
                    if (module != null)
                    {
                        module.Create(info);
                        serverModules.Add(module.ID, module);
                        module.Start();
                    }
                }
            }
            catch (Exception e)
            {
                Debuger.LogError(e.Message);
            }
        }
 public virtual void Create(ServerModuleInfo info)
 {
     serverModuleInfo = info;
     LOGTAG           = this.GetType().Name + "[" + info.ID + "," + info.Port + "]";
 }