protected override void LoadConfig() { base.LoadConfig(); _config = Config.ReadObject <MsgConfig>(); _messages = new MsgCollection { MessagesList = _config.Msgs }; _messagesQueue = new MsgCollection { MessagesList = _config.QueueMsgs }; if (_config.EnableQueueMessages || _config.QueueMsgs != null) { return; } _config.QueueMsgs = new List <MsgEntry> { new MsgEntry { TopString = "<color=#ffff00>You're in queue...</color>", BottomString = "<color=#add8e6>{AHEAD} players ahead of you.</color>" }, new MsgEntry { TopString = "<color=#add8e6>You're in queue...</color>", BottomString = "<color=#ffff00>{BEHIND} players behind you.</color>" } }; SaveConfig(); PrintWarning("Detected probably outdated config. New entries added. Check your config."); }
void test() { MsgConfigLoader xl = new MsgConfigLoader(); xl.msgConfigs = new List <MsgConfig>(); for (int i = 0; i < 5; ++i) { MsgConfig scfg = new MsgConfig(); scfg.mainId = 100; scfg.name = "MDM_GP_LOGON"; scfg.subcfgs = new List <MsgSubCfg>(); for (int j = 0; j < 2; ++j) { MsgSubCfg sub = new MsgSubCfg(); sub.assId = 1; sub.type = 0; sub.hasData = true; sub.rspType = "MSG_GP_R_LogonResult"; sub.handler = "MDM_GP_LOGON_Handler"; scfg.subcfgs.Add(sub); } xl.msgConfigs.Add(scfg); } XmlHelper.XmlSerializeToFile(xl, "G:/UnityProject/LotterySvn/trunk/Assets/test.xml", System.Text.Encoding.UTF8); }
protected override void LoadDefaultConfig() { _config = new MsgConfig { TimerFreq = .30f, EnableCyclicity = false, EnableRandomCyclicity = false, CyclicityFreq = 3.0f, Msgs = new List <MsgEntry> { new MsgEntry { TopString = "<color=#ffff00>Welcome to our server!</color>", BottomString = "<color=#add8e6>Enjoy your stay.</color>" }, new MsgEntry { TopString = "<color=#add8e6>Welcome to our server!</color>", BottomString = "<color=#ffff00>Enjoy your stay.</color>" } }, EnableQueueMessages = false, QueueMsgs = new List <MsgEntry> { new MsgEntry { TopString = "<color=##ffff00>You're in queue...</color>", BottomString = "<color=#add8e6>{AHEAD} players ahead of you.</color>" }, new MsgEntry { TopString = "<color=#add8e6>You're in queue...</color>", BottomString = "<color=#ffff00>{BEHIND} players behind you.</color>" } }, LastMessage = new MsgEntry { TopString = "<color=#ffff00>Welcome to our server!</color>", BottomString = "<color=#008000>Entering game...</color>" } }; }
public KafkaMsgReceive(MsgHandling _msgHandling, MsgConfig msgConfig) { kfkUrl = msgConfig.KafkaUrl; kfkGroup = msgConfig.KafkaGroup; this.msgHandling = _msgHandling; }
public NetMQMsgReceive( IHubContext <MessageHub> hubContext, MsgConfig msgConfig, MsgIntoDB _msgIntoDB, IMsgSend MsgSend) { this.hubContext = hubContext; _DataPublisherServePubString = msgConfig.MQUrlPublisherServePubString; //_DataPublisherServePubString = "tcp://192.168.31.28:6556"; this.msgIntoDB = _msgIntoDB; this.msgSend = MsgSend; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // 将配置文件作为单例注入容器 services.AddSingleton(Configuration); //配置任务Job services.AddTimedJob(); //Add session service services.AddSession(o => { o.IdleTimeout = TimeSpan.FromHours(2); }); //Add Tiantian Msg TiantianMsg.Config = MsgConfig.GetMsgConfig(); services.AddScoped <TiantianMsg>(); // Add framework services. services.AddMvc() .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver());//JSON首字母小写解决; }
void AnalzyPackage(Lopackage pkg, bool isGameSocket = false) { if (pkg == null) { return; } NetMessageHead head = pkg.head; //获取消息配置 MsgConfig msgCfg = msgCfgLoader.GetMsgConfig(head.bMainID); if (isGameSocket) { switch (Global.CurrentGameId) { case 10301800: //百家乐 if (baccaratMsgConfigLoader != null) { msgCfg = baccaratMsgConfigLoader.GetMsgConfig(head.bMainID); } break; } } if (msgCfg == null) { if (isGameSocket) { Debug.LogWarning("this messageid: " + head.bMainID + " this bAssistantID: " + head.bAssistantID + " doesn't has its config"); } return; } MsgSubCfg subCfg = msgCfg.GetMsgSubCfg(head.bAssistantID); if (subCfg == null) { if (isGameSocket) { Debug.LogWarning("this messageid: " + head.bMainID + " this bAssistantID: " + head.bAssistantID + " doesn't has its config"); } return; } //根据消息配置 获得处理类 以及 返回数据类型 Type rspType = Type.GetType(subCfg.rspType); if (rspType == null) { Debug.LogError("this messageid: " + head.bMainID + " this bAssistantID: " + head.bAssistantID + " do not have subCfg.rspType"); } Type InterfaceType = typeof(IHandler <>); InterfaceType = InterfaceType.MakeGenericType(rspType); Type handlerType = Type.GetType(subCfg.handler); if (handlerType == null) { Debug.LogError("this messageid: " + head.bMainID + " this bAssistantID: " + head.bAssistantID + " subCfg.handler error"); } object obj = Activator.CreateInstance(handlerType); //将处理类注入 context.injectionBinder.injector.Inject(obj); //调用处理类的 回调 object[] args = new object[2]; args[0] = head; if (subCfg.hasData) { if (pkg.objectData == null) { Debug.LogError("this messageid: " + head.bMainID + " this bAssistantID: " + head.bAssistantID + " pkg.objectData==null"); args[1] = null; //特殊处理 } else if (head.uMessageSize != pkg.objectData.Length + 20) { Debug.LogError("this messageid: " + head.bMainID + " this bAssistantID: " + head.bAssistantID + " pkg.head.uMessageSize != pkg.objectData.Length"); args[1] = null; //特殊处理 } else if (head.uMessageSize == pkg.objectData.Length + 20) { object dataObj = LoSocket.BytesToStruct(pkg.objectData, rspType); args[1] = dataObj; } else { Debug.LogError("this messageid: " + head.bMainID + " this bAssistantID: " + head.bAssistantID + " other error"); args[1] = null; } } else { args[1] = null; } InterfaceType.InvokeMember("OnReceive", BindingFlags.Default | BindingFlags.InvokeMethod, null, obj, args); obj = null; }