Esempio n. 1
0
        static string DealWithInterfaceAndObj(interfaceOfHM.ListenInterface objI, CommonClass.Command c, string notifyJson)
        {
            string outPut = "haveNothingToReturn";
            {
                // CommonClass.Command c = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonClass.Command>(notifyJson);

                switch (c.c)
                {
                case "PlayerAdd_V2":
                {
                    CommonClass.PlayerAdd_V2 addItem = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.PlayerAdd_V2>(notifyJson);
                    var result = objI.AddPlayer(addItem);
                    outPut = result;
                }; break;

                case "GetPosition":
                {
                    CommonClass.GetPosition getPosition = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.GetPosition>(notifyJson);
                    //string fromUrl;
                    var GPResult = objI.GetPosition(getPosition);
                    if (GPResult.Success)
                    {
                        CommonClass.GetPositionNotify_v2 notify = new CommonClass.GetPositionNotify_v2()
                        {
                            c                 = "GetPositionNotify_v2",
                            fp                = GPResult.Fp,
                            WebSocketID       = GPResult.WebSocketID,
                            key               = getPosition.Key,
                            PlayerName        = GPResult.PlayerName,
                            positionInStation = GPResult.positionInStation,
                            fPIndex           = GPResult.fPIndex
                        };

                        Startup.sendMsg(GPResult.FromUrl, Newtonsoft.Json.JsonConvert.SerializeObject(notify));
                        var notifyMsgs = GPResult.NotifyMsgs;
                        for (var i = 0; i < notifyMsgs.Count; i += 2)
                        {
                            Startup.sendMsg(notifyMsgs[i], notifyMsgs[i + 1]);
                        }
                    }
                    outPut = "ok";
                }; break;

                case "SetPromote":
                {
                    CommonClass.SetPromote sp = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetPromote>(notifyJson);
                    var result = objI.updatePromote(sp);
                    outPut = "ok";
                    //await context.Response.WriteAsync("ok");
                }; break;

                case "SetAbility":
                {
                    CommonClass.SetAbility sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetAbility>(notifyJson);
                    objI.SetAbility(sa);
                    outPut = "ok";
                }; break;

                case "PlayerCheck":
                {
                    CommonClass.PlayerCheck checkItem = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.PlayerCheck>(notifyJson);
                    var result = objI.UpdatePlayer(checkItem);
                    outPut = result;
                }; break;

                case "SetCollect":
                {
                    CommonClass.SetCollect sc = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetCollect>(notifyJson);
                    var result = objI.updateCollect(sc);
                    outPut = "ok";
                    //await context.Response.WriteAsync("ok");
                }; break;

                case "SetAttack":
                {
                    CommonClass.SetAttack sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetAttack>(notifyJson);
                    var result = objI.updateAttack(sa);
                    outPut = "ok";
                    //await context.Response.WriteAsync("ok");
                }; break;

                //case "SetBust":
                //    {
                //        CommonClass.SetBust sa = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonClass.SetBust>(notifyJson);
                //        var result = objI.updateBust(sa);
                //        outPut = "ok";
                //        //await context.Response.WriteAsync("ok");
                //    }; break;
                case "GetFrequency":
                {
                    outPut = Program.rm.GetFrequency().ToString();
                }; break;

                case "OrderToReturn":
                {
                    CommonClass.OrderToReturn otr = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.OrderToReturn>(notifyJson);
                    objI.OrderToReturn(otr);
                    outPut = "ok";
                }; break;

                case "SaveMoney":
                {
                    CommonClass.SaveMoney saveMoney = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SaveMoney>(notifyJson);
                    objI.SaveMoney(saveMoney);
                    outPut = "ok";
                }; break;

                //case "SetTax":
                //    {
                //        CommonClass.SetTax st = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonClass.SetTax>(notifyJson);
                //        var result = Program.rm.updateTax(st);
                //        outPut = "ok";
                //        //await context.Response.WriteAsync("ok");
                //    }; break;
                case "MarketPrice":
                {
                    CommonClass.MarketPrice sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MarketPrice>(notifyJson);

                    objI.MarketUpdate(sa);
                }; break;

                case "SetBuyDiamond":
                {
                    CommonClass.SetBuyDiamond bd = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetBuyDiamond>(notifyJson);

                    objI.Buy(bd);
                }; break;

                case "SetSellDiamond":
                {
                    CommonClass.SetSellDiamond ss = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetSellDiamond>(notifyJson);

                    objI.Sell(ss);
                }; break;

                case "OrderToSubsidize":
                {
                    CommonClass.OrderToSubsidize ots = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.OrderToSubsidize>(notifyJson);
                    objI.OrderToSubsidize(ots);
                    outPut = "ok";
                }; break;

                case "DialogMsg":
                {
                    CommonClass.DialogMsg dm = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.DialogMsg>(notifyJson);
                    objI.SendMsg(dm);
                    outPut = "ok";
                }; break;

                case "SetSelectDriver":
                {
                    CommonClass.SetSelectDriver dm = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetSelectDriver>(notifyJson);
                    objI.SelectDriver(dm);
                    outPut = "ok";
                }; break;

                case "MagicSkill":
                {
                    CommonClass.MagicSkill ms = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MagicSkill>(notifyJson);
                    var result = objI.updateMagic(ms);
                    outPut = "ok";
                }; break;

                case "View":
                {
                    CommonClass.View v = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.View>(notifyJson);
                    var result         = objI.updateView(v);
                    outPut = "ok";
                }; break;

                case "GetFirstRoad":
                {
                    //CommonClass.View v = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonClass.View>(notifyJson);
                    var result = objI.GetFirstRoad();
                    outPut = result;
                }; break;

                case "DrawRoad":
                {
                    CommonClass.MapEditor.DrawRoad v = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MapEditor.DrawRoad>(notifyJson);
                    outPut = objI.DrawRoad(v);
                }; break;

                case "NextCross":
                {
                    CommonClass.MapEditor.NextCross v = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MapEditor.NextCross>(notifyJson);
                    outPut = objI.NextCross(v);
                }; break;

                case "PreviousCross":
                {
                    CommonClass.MapEditor.PreviousCross v = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MapEditor.PreviousCross>(notifyJson);
                    outPut = objI.PreviousCross(v);
                }; break;

                case "GetCatege":
                {
                    CommonClass.MapEditor.GetCatege gc = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MapEditor.GetCatege>(notifyJson);
                    outPut = objI.GetCatege(gc);
                    // Console.WriteLine(outPut);
                }; break;

                case "GetAbtractModels":
                {
                    CommonClass.MapEditor.GetAbtractModels gam = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MapEditor.GetAbtractModels>(notifyJson);
                    outPut = objI.GetAbtractModels(gam);
                    // Console.WriteLine(outPut);
                }; break;

                case "SaveObjInfo":
                {
                    CommonClass.MapEditor.SaveObjInfo soi = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MapEditor.SaveObjInfo>(notifyJson);
                    outPut = objI.SaveObjInfo(soi);
                }; break;

                case "ShowOBJFile":
                {
                    CommonClass.MapEditor.ShowOBJFile sof = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MapEditor.ShowOBJFile>(notifyJson);
                    outPut = objI.ShowOBJFile(sof);
                }; break;

                case "UpdateObjInfo":
                {
                    CommonClass.MapEditor.UpdateObjInfo uoi = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MapEditor.UpdateObjInfo>(notifyJson);
                    outPut = objI.UpdateObjInfo(uoi);
                }; break;

                case "DelObjInfo":
                {
                    CommonClass.MapEditor.DelObjInfo doi = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MapEditor.DelObjInfo>(notifyJson);
                    outPut = objI.DelObjInfo(doi);
                }; break;
                }
            }
            {
                return(outPut);
            }
        }
Esempio n. 2
0
        private static async Task <string> DealWith(string notifyJson)
        {
            Console.WriteLine($"notify receive:{notifyJson}");
            File.AppendAllText("log/d.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}-{notifyJson}{Environment.NewLine}");
            //File.AppendText("",)
            // CommonClass.TeamCreateFinish teamCreateFinish = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonClass.TeamCreateFinish>(notifyJson);
            string outPut = "haveNothingToReturn";
            {
                CommonClass.Command c = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.Command>(notifyJson);

                switch (c.c)
                {
                case "PlayerAdd_V2":
                {
                    CommonClass.PlayerAdd_V2 addItem = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.PlayerAdd_V2>(notifyJson);
                    var result = Program.rm.AddPlayer(addItem);
                    outPut = result;
                }; break;

                case "GetPosition":
                {
                    CommonClass.GetPosition getPosition = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.GetPosition>(notifyJson);
                    //string fromUrl;
                    var GPResult = Program.rm.GetPosition(getPosition);
                    if (GPResult.Success)
                    {
                        CommonClass.GetPositionNotify_v2 notify = new CommonClass.GetPositionNotify_v2()
                        {
                            c                 = "GetPositionNotify_v2",
                            fp                = GPResult.Fp,
                            WebSocketID       = GPResult.WebSocketID,
                            key               = getPosition.Key,
                            PlayerName        = GPResult.PlayerName,
                            positionInStation = GPResult.positionInStation
                        };

                        Startup.sendMsg(GPResult.FromUrl, Newtonsoft.Json.JsonConvert.SerializeObject(notify));
                        var notifyMsgs = GPResult.NotifyMsgs;
                        for (var i = 0; i < notifyMsgs.Count; i += 2)
                        {
                            Startup.sendMsg(notifyMsgs[i], notifyMsgs[i + 1]);
                        }
                    }
                    outPut = "ok";
                }; break;

                case "SetPromote":
                {
                    CommonClass.SetPromote sp = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetPromote>(notifyJson);
                    var result = Program.rm.updatePromote(sp);
                    outPut = "ok";
                    //await context.Response.WriteAsync("ok");
                }; break;

                case "SetAbility":
                {
                    CommonClass.SetAbility sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetAbility>(notifyJson);
                    Program.rm.SetAbility(sa);
                    outPut = "ok";
                }; break;

                case "PlayerCheck":
                {
                    CommonClass.PlayerCheck checkItem = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.PlayerCheck>(notifyJson);
                    var result = Program.rm.UpdatePlayer(checkItem);
                    outPut = result;
                }; break;

                case "SetCollect":
                {
                    CommonClass.SetCollect sc = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetCollect>(notifyJson);
                    var result = Program.rm.updateCollect(sc);
                    outPut = "ok";
                    //await context.Response.WriteAsync("ok");
                }; break;

                case "SetAttack":
                {
                    CommonClass.SetAttack sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetAttack>(notifyJson);
                    var result = Program.rm.updateAttack(sa);
                    outPut = "ok";
                    //await context.Response.WriteAsync("ok");
                }; break;

                case "SetBust":
                {
                    CommonClass.SetBust sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetBust>(notifyJson);
                    var result             = Program.rm.updateBust(sa);
                    outPut = "ok";
                    //await context.Response.WriteAsync("ok");
                }; break;

                case "GetFrequency":
                {
                    outPut = Program.rm.GetFrequency().ToString();
                }; break;

                case "OrderToReturn":
                {
                    CommonClass.OrderToReturn otr = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.OrderToReturn>(notifyJson);
                    Program.rm.OrderToReturn(otr);
                    outPut = "ok";
                }; break;

                case "SaveMoney":
                {
                    CommonClass.SaveMoney saveMoney = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SaveMoney>(notifyJson);
                    Program.rm.SaveMoney(saveMoney);
                    outPut = "ok";
                }; break;

                case "SetTax":
                {
                    CommonClass.SetTax st = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetTax>(notifyJson);
                    var result            = Program.rm.updateTax(st);
                    outPut = "ok";
                    //await context.Response.WriteAsync("ok");
                }; break;

                case "MarketPrice":
                {
                    CommonClass.MarketPrice sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MarketPrice>(notifyJson);

                    Program.rm.Market.Update(sa);
                }; break;

                case "SetBuyDiamond":
                {
                    CommonClass.SetBuyDiamond bd = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetBuyDiamond>(notifyJson);

                    Program.rm.Buy(bd);
                }; break;

                case "SetSellDiamond":
                {
                    CommonClass.SetSellDiamond ss = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetSellDiamond>(notifyJson);

                    Program.rm.Sell(ss);
                }; break;

                case "OrderToSubsidize":
                {
                    CommonClass.OrderToSubsidize ots = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.OrderToSubsidize>(notifyJson);
                    Program.rm.OrderToSubsidize(ots);
                    outPut = "ok";
                }; break;

                case "DialogMsg":
                {
                    CommonClass.DialogMsg dm = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.DialogMsg>(notifyJson);
                    Program.rm.SendMsg(dm);
                    outPut = "ok";
                }; break;
                }
            }
            {
                return(outPut);
            }
        }
Esempio n. 3
0
        private static async Task <string> DealWith(string notifyJson)
        {
            Console.WriteLine($"notify receive:{notifyJson}");
            // CommonClass.TeamCreateFinish teamCreateFinish = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonClass.TeamCreateFinish>(notifyJson);
            string outPut = "haveNothingToReturn";
            {
                {
                    Console.WriteLine($"json:{notifyJson}");

                    var t = Convert.ToInt32((DateTime.Now - Program.startTime).TotalMilliseconds);
                    //File.AppendAllText("debugLog.txt", Newtonsoft.Json.JsonConvert.SerializeObject
                    //    (
                    //    new { t = t, notifyJson = notifyJson }
                    //    ));
                    File.AppendAllText("debugLog.txt", $"awaitF({t})" + Environment.NewLine);
                    File.AppendAllText("debugLog.txt", $"SendInfomation({notifyJson})" + Environment.NewLine);
                    File.AppendAllText("debugLog.txt", "" + Environment.NewLine);

                    Console.WriteLine($"notify receive:{notifyJson}");
                    CommonClass.Command c = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.Command>(notifyJson);

                    switch (c.c)
                    {
                    case "PlayerAdd":
                    {
                        CommonClass.PlayerAdd addItem = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.PlayerAdd>(notifyJson);
                        var result = BaseInfomation.rm.AddPlayer(addItem);
                        outPut = result;
                    }; break;

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

                    case "Map":
                    {
                        CommonClass.Map map = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.Map>(notifyJson);
                        switch (map.DataType)
                        {
                        case "All":
                        {
                            //    public void getAll(out List<double[]> meshPoints, out List<object> listOfCrosses)
                            List <double[]> meshPoints;
                            List <object>   listOfCrosses;
                            Program.dt.getAll(out meshPoints, out listOfCrosses);
                            var json = Newtonsoft.Json.JsonConvert.SerializeObject(new { meshPoints = meshPoints, listOfCrosses = listOfCrosses });
                            outPut = json;
                        }; break;
                        }
                    }; break;

                    case "GetPosition":
                    {
                        CommonClass.GetPosition getPosition = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.GetPosition>(notifyJson);
                        //string fromUrl;
                        var GPResult = await BaseInfomation.rm.GetPosition(getPosition);

                        if (GPResult.Success)
                        {
                            CommonClass.GetPositionNotify notify = new CommonClass.GetPositionNotify()
                            {
                                c           = "GetPositionNotify",
                                fp          = GPResult.Fp,
                                WebSocketID = GPResult.WebSocketID,
                                carsNames   = GPResult.CarsNames,
                                key         = getPosition.Key,
                                PlayerName  = GPResult.PlayerName
                            };

                            await sendMsg(GPResult.FromUrl, Newtonsoft.Json.JsonConvert.SerializeObject(notify), true);

                            var notifyMsgs = GPResult.NotifyMsgs;
                            for (var i = 0; i < notifyMsgs.Count; i += 2)
                            {
                                await sendMsg(notifyMsgs[i], notifyMsgs[i + 1], true);
                            }
                        }
                        outPut = "ok";
                    }; break;

                    case "FinishTask":
                    {
                    }; break;

                    case "SetPromote":
                    {
                        CommonClass.SetPromote sp = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetPromote>(notifyJson);
                        var result = await BaseInfomation.rm.updatePromote(sp);

                        outPut = "ok";
                        //await context.Response.WriteAsync("ok");
                    }; break;

                    case "SetCollect":
                    {
                        CommonClass.SetCollect sc = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetCollect>(notifyJson);
                        var result = await BaseInfomation.rm.updateCollect(sc);

                        outPut = "ok";
                        //await context.Response.WriteAsync("ok");
                    }; break;

                    case "SetAttack":
                    {
                        CommonClass.SetAttack sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetAttack>(notifyJson);
                        var result = await BaseInfomation.rm.updateAttack(sa);

                        outPut = "ok";
                        //await context.Response.WriteAsync("ok");
                    }; break;

                    case "SetBust":
                    {
                        CommonClass.SetBust sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetBust>(notifyJson);
                        var result             = await BaseInfomation.rm.updateBust(sa);

                        outPut = "ok";
                        //await context.Response.WriteAsync("ok");
                    }; break;

                    case "SetTax":
                    {
                        CommonClass.SetTax st = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetTax>(notifyJson);
                        var result            = await BaseInfomation.rm.updateTax(st);

                        outPut = "ok";
                        //await context.Response.WriteAsync("ok");
                    }; break;

                    case "DialogMsg":
                    {
                        CommonClass.DialogMsg dm = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.DialogMsg>(notifyJson);
                        await BaseInfomation.rm.SendMsg(dm);

                        outPut = "ok";
                    }; break;

                    case "SetAbility":
                    {
                        CommonClass.SetAbility sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetAbility>(notifyJson);
                        await BaseInfomation.rm.SetAbility(sa);

                        outPut = "ok";
                    }; break;

                    case "OrderToReturn":
                    {
                        CommonClass.OrderToReturn otr = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.OrderToReturn>(notifyJson);
                        await BaseInfomation.rm.OrderToReturn(otr);

                        outPut = "ok";
                    }; break;

                    case "SaveMoney":
                    {
                        CommonClass.SaveMoney saveMoney = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SaveMoney>(notifyJson);
                        await BaseInfomation.rm.SaveMoney(saveMoney);

                        outPut = "ok";
                    }; break;

                    case "OrderToSubsidize":
                    {
                        CommonClass.OrderToSubsidize ots = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.OrderToSubsidize>(notifyJson);
                        await BaseInfomation.rm.OrderToSubsidize(ots);

                        outPut = "ok";
                    }; break;

                    case "SetBustAttack":
                    {
                        CommonClass.SetAttack sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetAttack>(notifyJson);
                        var result = await BaseInfomation.rm.updateAttack(sa);

                        outPut = "ok";
                        //await context.Response.WriteAsync("ok");
                    }; break;

                    case "GetFrequency":
                    {
                        outPut = BaseInfomation.rm.GetFrequency().ToString();
                    }; break;

                    case "MarketPrice":
                    {
                        CommonClass.MarketPrice sa = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.MarketPrice>(notifyJson);

                        BaseInfomation.rm.Market.Update(sa);
                    }; break;

                    case "SetBuyDiamond":
                    {
                        CommonClass.SetBuyDiamond bd = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetBuyDiamond>(notifyJson);

                        BaseInfomation.rm.Buy(bd);
                    }; break;

                    case "SetSellDiamond":
                    {
                        CommonClass.SetSellDiamond ss = Newtonsoft.Json.JsonConvert.DeserializeObject <CommonClass.SetSellDiamond>(notifyJson);

                        BaseInfomation.rm.Sell(ss);
                    }; break;
                    }
                }
            }
            {
                return(outPut);
            }
        }