Exemplo n.º 1
0
        private static void monitor(IApplicationBuilder app)
        {
            app.Run(async context =>
            {
                if (context.WebSockets.IsWebSocketRequest)
                {
                    var webSocket = await context.WebSockets.AcceptWebSocketAsync();
                    await dealWithMonitor(webSocket);
                }
            });
            return;

            app.Run(async context =>
            {
                if (context.Request.Method.ToLower() == "post")
                {
                    var notifyJson = getBodyStr(context);

                    // var t = Convert.ToInt64((DateTime.Now - Program.startTime).TotalMilliseconds);

                    Console.WriteLine($"monitor receive:{notifyJson}");
                    CommonClass.Monitor m = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.Monitor>(notifyJson);

                    switch (m.c)
                    {
                    case "CheckPlayersCarState":
                        {
                            CommonClass.CheckPlayersCarState cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayersCarState>(notifyJson);
                            var result = BaseInfomation.rm.Monitor(cpcs);
                            await context.Response.WriteAsync(result);
                        }; break;

                    case "CheckPlayersMoney":
                        {
                            CommonClass.CheckPlayersMoney cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayersMoney>(notifyJson);
                            var result = BaseInfomation.rm.Monitor(cpcs);
                            await context.Response.WriteAsync(result);
                        }; break;

                    case "CheckPlayerCostBusiness":
                        {
                            CommonClass.CheckPlayerCostBusiness cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayerCostBusiness>(notifyJson);
                            var result = BaseInfomation.rm.Monitor(cpcs);
                            await context.Response.WriteAsync(result);
                        }; break;

                    case "CheckPromoteDiamondCount":
                        {
                            CommonClass.CheckPromoteDiamondCount cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPromoteDiamondCount>(notifyJson);
                            var result = BaseInfomation.rm.Monitor(cpcs);
                            await context.Response.WriteAsync(result);
                        }; break;

                    case "CheckPlayerCarPuporse":
                        {
                            CommonClass.CheckPlayerCarPuporse cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayerCarPuporse>(notifyJson);
                            var result = BaseInfomation.rm.Monitor(cpcs);
                            await context.Response.WriteAsync(result);
                        }; break;

                    case "CheckPlayerCostVolume":
                        {
                            CommonClass.CheckPlayerCostVolume cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayerCostVolume>(notifyJson);
                            var result = BaseInfomation.rm.Monitor(cpcs);
                            await context.Response.WriteAsync(result);
                        }; break;
                    }
                }
            });
        }
Exemplo n.º 2
0
        private static string DealWithMonitorValue(string notifyJson)
        {
            Console.WriteLine($"Monitor notify receive:{notifyJson}");

            string outPut = "haveNothingToReturn";

            {
                //  var notifyJson = returnResult.result;

                // Console.WriteLine($"json:{notifyJson}");


                Console.WriteLine($"monitor receive:{notifyJson}");
                CommonClass.Monitor m = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.Monitor>(notifyJson);

                switch (m.c)
                {
                case "CheckPlayersCarState":
                {
                    CommonClass.CheckPlayersCarState cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayersCarState>(notifyJson);
                    var result = BaseInfomation.rm.Monitor(cpcs);
                    outPut = result;
                }; break;

                case "CheckPlayersMoney":
                {
                    CommonClass.CheckPlayersMoney cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayersMoney>(notifyJson);
                    var result = BaseInfomation.rm.Monitor(cpcs);
                    outPut = result;
                }; break;

                case "CheckPlayerCostBusiness":
                {
                    CommonClass.CheckPlayerCostBusiness cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayerCostBusiness>(notifyJson);
                    var result = BaseInfomation.rm.Monitor(cpcs);
                    outPut = result;
                }; break;

                case "CheckPromoteDiamondCount":
                {
                    CommonClass.CheckPromoteDiamondCount cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPromoteDiamondCount>(notifyJson);
                    var result = BaseInfomation.rm.Monitor(cpcs);
                    outPut = result;
                }; break;

                case "CheckPlayerCarPuporse":
                {
                    CommonClass.CheckPlayerCarPuporse cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayerCarPuporse>(notifyJson);
                    var result = BaseInfomation.rm.Monitor(cpcs);
                    outPut = result;
                }; break;

                case "CheckPlayerCostVolume":
                {
                    CommonClass.CheckPlayerCostVolume cpcs = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.CheckPlayerCostVolume>(notifyJson);
                    var result = BaseInfomation.rm.Monitor(cpcs);
                    outPut = result;
                }; break;

                case "All":
                {
                    CommonClass.All all    = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.All>(notifyJson);
                    var             result = BaseInfomation.rm.Monitor(all);
                    return(result);
                }; break;
                }
            }
            return(outPut);
        }