Пример #1
0
 private void onSetFavLogReqSuccess(BaseWWWRequest obj)
 {
     try
     {
         BasicResponse response = new JsonFx.Json.JsonReader().Read <BasicResponse>(this.UTF8String);
         base.responseData = response;
         if (response.eid != 0)
         {
             this.onSetFavLogReqFail(obj);
         }
         else
         {
             if (this.settingFavLog != null)
             {
                 this.settingFavLog.ToggleFav();
             }
             this.OnSetFavLogSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onSetFavLogReqFail(obj);
     }
 }
Пример #2
0
        public void handleMessage(Message msg)
        {
            if (msg is RoomEnterMessage)
            {
                RoomEnterMessage rms = (RoomEnterMessage)msg;
                this.nomssg.Add(rms.roomName);

            }

            if (msg is RoomInfoMessage)
            {
                Console.WriteLine("joinleave bearbeitet: " + msg.getRawText());
                //"removed";
                //"updated";
                JsonReader jsonReader = new JsonReader();
                Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
                string roomname = (string)dictionary["roomName"];

                

                if (msg.getRawText().Contains("removed"))
                {
                    Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["removed"];

                    for (int i = 0; i < d.Length; i++)
                    {
                        string ltext = d[i]["name"] + " has left the room";
                        
                        RoomChatMessageMessage leftmessage = new RoomChatMessageMessage(roomname, "<color=#777460>" + ltext + "</color>");
                        App.ChatUI.handleMessage(leftmessage);
                        App.ArenaChat.ChatRooms.ChatMessage(leftmessage);
                    }

                }

                if (msg.getRawText().Contains("updated") && this.nomssg.Contains(roomname))
                {
                    nomssg.RemoveAll(item => item == roomname);
                }
                else
                {
                    if (msg.getRawText().Contains("updated"))
                    {
                        Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["updated"];

                        for (int i = 0; i < d.Length; i++)
                        {
                            string ltext = d[i]["name"] + " has joined the room";
                            RoomChatMessageMessage leftmessage = new RoomChatMessageMessage(roomname, "<color=#777460>" + ltext + "</color>");
                            App.ChatUI.handleMessage(leftmessage);
                            App.ArenaChat.ChatRooms.ChatMessage(leftmessage);
                        }

                    }

                }
            }
            
            return;
        }
 private void onReqWeddingSuccess(BaseWWWRequest obj)
 {
     try
     {
         WeddingResponse response = new JsonFx.Json.JsonReader().Read <WeddingResponse>(this.UTF8String);
         base.responseData = response;
         if (response.eid != 0)
         {
             this.onReqWeddingFail(obj);
         }
         else
         {
             if (response.shipVO != null)
             {
                 foreach (UserShip ship in response.shipVO)
                 {
                     GameData.instance.UpdateUserShip(ship);
                 }
             }
             if (response.packageVo != null)
             {
                 GameData.instance.UpdateUserItems(response.packageVo);
             }
             this.OnWeddingSuccess(EventArgs.Empty);
             ServerRequestManager.instance.refreashUIData();
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onReqWeddingFail(obj);
     }
 }
Пример #4
0
 private void onBuildSuccess(BaseWWWRequest obj)
 {
     try
     {
         BuildShipData data = new JsonFx.Json.JsonReader().Read <BuildShipData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.onBuildFail(obj);
         }
         else
         {
             GameData.instance.UserDocks = data.dockVo;
             GameData.instance.UpdateUserItems(data.packageVo);
             if (data.userVo != null)
             {
                 GameData.instance.UserInfo.UpdateResource(data.userVo);
             }
             z.instance.OnbuildShipSuccess(dockid, data);
             this.OnBuildShipSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onBuildFail(obj);
     }
 }
Пример #5
0
 private void onReqGetConfigSuccess(BaseWWWRequest obj)
 {
     try
     {
         GetPVEConfigData data;
         if (this.needZip)
         {
             data = new JsonFx.Json.JsonReader().Read <GetPVEConfigData>(base.UTF8String);
         }
         else
         {
             data = new JsonFx.Json.JsonReader().Read <GetPVEConfigData>(this.UTF8String);
         }
         base.responseData = data;
         if (data.eid != 0)
         {
             this.onReqGetConfigFail(obj);
         }
         else
         {
             PVEConfigs instance = PVEConfigs.instance;
             instance.SetChapters(data.pve);
             instance.SetLevels(data.pveLevel);
             instance.SetNodes(data.pveNode);
             //MonoBehaviour.print("onReqGetConfigSuccess");
             this.OnGetConfigSuccess(EventArgs.Empty);
             haveGetPVEConfig = true;
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onReqGetConfigFail(obj);
     }
 }
Пример #6
0
 private void reqGetUserDataSuccess(BaseWWWRequest obj)
 {
     try
     {
         GetCampaignDataResponse response = new JsonFx.Json.JsonReader().Read <GetCampaignDataResponse>(this.UTF8String);
         base.responseData = response;
         if (response.eid != 0)
         {
             this.reqGetUserDataFail(obj);
         }
         else
         {
             if ((response.shipCampaign != null) && (response.shipCampaignLevel != null))
             {
                 PVEConfigs.instance.SetCampaignChapters(response.shipCampaign);
                 PVEConfigs.instance.SetCampaignLevels(response.shipCampaignLevel);
                 haveGetConfig = true;
             }
             GameData.instance.SetOpenedPVECampaignLevels(response.canCampaignChallengeLevel);
             GameData.instance.SetCampaignChapterTimesInfo(response.campaignChallenge);
             if (response.passInfo != null)
             {
                 GameData.instance.TotalCampainInfo = response.passInfo;
             }
             this.OnGetCampaignDataSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.reqGetUserDataFail(obj);
     }
 }
Пример #7
0
            public void readJsonfromGoogle(string txt)
            {
                JsonReader jsonReader = new JsonReader();
                Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(txt);
                dictionary = (Dictionary<string, object>)dictionary["feed"];
                Dictionary<string, object>[] entrys = (Dictionary<string, object>[])dictionary["entry"];
                for (int i = 0; i < entrys.GetLength(0); i++)
                {
                    /*for (int j = 0; j < 4; j++)
                    {
                        dictionary = (Dictionary<string, object>)entrys[i]["gsx$r"+(j+1)];
                        Console.WriteLine((string)dictionary["$t"]);
                    
                    }*/

                    dictionary = (Dictionary<string, object>)entrys[i]["gsx$r1"];
                    if (((string)dictionary["$t"]).ToLower() == "version")
                    {
                        dictionary = (Dictionary<string, object>)entrys[i]["gsx$r2"];
                        this.newestversion=(string)dictionary["$t"];
                        Console.WriteLine("version string recived");
                    }

                }
            }
Пример #8
0
 private void onReqChangeSuccess(BaseWWWRequest obj)
 {
     try
     {
         DestroyShipData data = new JsonFx.Json.JsonReader().Read<DestroyShipData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.onReqChangeFail(obj);
         }
         else
         {
             if (data.userVo != null)
             {
                 GameData.instance.UserInfo.UpdateResource(data.userVo);
             }
             if (data.equipmentVo != null)
             {
                 GameData.instance.SetUserEquipments(data.equipmentVo);
             }
             if (data.detailInfo != null)
             {
                 GameData.instance.UserInfo.UpdateDetailInfo(data.detailInfo);
             }
             this.UpdateShips();
             this.OnDestroySuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onReqChangeFail(obj);
     }
 }
Пример #9
0
 private void onReqChangeSuccess(BaseWWWRequest obj)
 {
     try
     {
         ChangeEquipData data = new JsonFx.Json.JsonReader().Read <ChangeEquipData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.onReqChangeFail(obj);
         }
         else
         {
             if (data.shipVO != null)
             {
                 GameData.instance.UpdateUserShip(data.shipVO);
             }
             if (data.detailInfo != null)
             {
                 GameData.instance.UserInfo.UpdateDetailInfo(data.detailInfo);
             }
             this.UpdateEquip();
             this.OnChangeEquipSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onReqChangeFail(obj);
     }
 }
Пример #10
0
        public object Convert(int operation, string packet)
        {
            object _packet = null;

            CharacterOperation key = (CharacterOperation)operation;

            JsonReaderSettings settings = new JsonReaderSettings();
            settings.AddTypeConverter (new VectorConverter());
            settings.AddTypeConverter (new QuaternionConverter());

            JsonReader jsonReader = new JsonReader(packet, settings);

            switch(key)
            {
                case CharacterOperation.GROUNDCLICK:
                    _packet = jsonReader.Deserialize<GroundClick>();
                    break;
                case CharacterOperation.INSTANTIATE:
                    _packet = jsonReader.Deserialize<InstantiateChar>();
                    break;
                case CharacterOperation.DESTROY:
                    _packet = jsonReader.Deserialize<DestroyChar>();
                    break;
                default:
                    break;
            }

            return _packet;
        }
Пример #11
0
        /// <summary>
        /// Deserialize the specified message using either JSONFX or NEWTONSOFT.JSON.
        /// The functionality is based on the pre-compiler flag
        /// </summary>
        /// <param name="message">Message.</param>
        public static T Deserialize <T> (string message)
        {
            object retMessage;

                                                #if (USE_JSONFX) || (USE_JSONFX_UNITY)
            var reader = new JsonFx.Json.JsonReader();
            retMessage = reader.Read <T> (message);
                                                #elif (USE_JSONFX_UNITY_IOS)
            UnityEngine.Debug.Log("message: " + message);
            retMessage = JsonReader.Deserialize <T>(message);
                                                #elif (USE_MiniJSON)
            UnityEngine.Debug.Log("message: " + message);
            object retMessage1   = Json.Deserialize(message) as object;
            Type   type          = typeof(T);
            var    expectedType2 = typeof(object[]);
            if (expectedType2.IsAssignableFrom(type))
            {
                retMessage = ((System.Collections.IEnumerable)retMessage1).Cast <object> ().ToArray();
            }
            else
            {
                retMessage = retMessage1;
            }
                                                #else
            retMessage = JsonConvert.DeserializeObject <T> (message);
                                                #endif
            return((T)retMessage);
        }
Пример #12
0
 private void reqGetShipSuccess(BaseWWWRequest obj)
 {
     try
     {
         GetRepairData data = new JsonFx.Json.JsonReader().Read <GetRepairData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.reqGetShipFail(obj);
         }
         else
         {
             if (data.shipVO != null)
             {
                 GameData.instance.UpdateUserShip(data.shipVO);
             }
             if (data.repairDockVo != null)
             {
                 GameData.instance.SetRepairDocks(data.repairDockVo);
             }
             z.log("[治(he)疗(xie)少女完毕] ... " + data.shipVO.ship.title + " Lv." + data.shipVO.level);
             this.OnGetShipSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.reqGetShipFail(obj);
     }
 }
Пример #13
0
        public List<dynamic> ExtractAppRevenueData(string appName, string queryString)
        {
            var revenueData = DistimoService.GetDistimoData(SupportedDistimoApis.Revenues, queryString);

            var reader = new JsonReader();
            dynamic output = reader.Read(revenueData);

            List<dynamic> filteredList = new List<dynamic>();

            try
            {
                foreach (dynamic line in output.lines)
                {
                    string localAppName = line.data.application;

                    if (localAppName.Contains(appName))
                        filteredList.Add(line);
                }
            }
            catch (RuntimeBinderException)
            {
                // too many requests, try again
                Thread.Sleep(1100);
                return ExtractAppRevenueData(appName, queryString);
            }

            return filteredList;
        }
Пример #14
0
 private void onReqChangeSuccess(BaseWWWRequest obj)
 {
     try
     {
         ChangeEquipData data = new JsonFx.Json.JsonReader().Read<ChangeEquipData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.onReqChangeFail(obj);
         }
         else
         {
             if (data.shipVO != null)
             {
                 GameData.instance.UpdateUserShip(data.shipVO);
             }
             if (data.detailInfo != null)
             {
                 GameData.instance.UserInfo.UpdateDetailInfo(data.detailInfo);
             }
             this.UpdateEquip();
             this.OnChangeEquipSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onReqChangeFail(obj);
     }
 }
Пример #15
0
 private List<string> JobList()
 {
     List<string> Jobs = new List<string>();
        string URL = Deployinator.Config.JenkinsUrl + "/api/json";
        Log.Info("requesting " + URL);
        HttpWebRequest Req = (HttpWebRequest)WebRequest.Create(URL);
        HttpWebResponse Resp = (HttpWebResponse)Req.GetResponse();
        if ( Resp.StatusCode == System.Net.HttpStatusCode.OK)
             {
                  System.IO.Stream ResponseStream = Resp.GetResponseStream();
                  System.IO.StreamReader StreamReader = new System.IO.StreamReader(ResponseStream);
                  JsonReader Reader = new JsonReader();
                  String Json = StreamReader.ReadToEnd();
                  Dictionary<string, Object> JsonDict = Reader.Read<Dictionary<string, Object>>(Json);
                  Dictionary<string, Object>[] JsonJobs = (Dictionary<string, Object>[]) JsonDict["jobs"];
                  for ( int i = 0 ; i < JsonJobs.Length ; i++ )
                       {
                            Dictionary<string, Object> JsonJob = (Dictionary<string, Object>) JsonJobs[i];
                            Jobs.Add((string)JsonJob["name"]);
                       }
             }
        else
             {
                  Log.Info("returned non 200 " + Resp.StatusCode.ToString());
             }
        return Jobs;
 }
Пример #16
0
 private void reqStartSuccess(BaseWWWRequest obj)
 {
     try
     {
         StartExploreResponse response = new JsonFx.Json.JsonReader().Read <StartExploreResponse>(this.UTF8String);
         base.responseData = response;
         if (response.eid != 0)
         {
             this.resStartFail(obj);
         }
         else
         {
             GameData.instance.UpdatePVEExplore(response.pveExploreVo);
             if (response.userResVo != null)
             {
                 GameData.instance.UserInfo.UpdateResource(response.userResVo);
             }
             z.log("[远征开始]...");
             this.OnStartExploreSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         //Form1.log(exception);
         this.resStartFail(obj);
     }
 }
Пример #17
0
 public JsonTcpCommunication(TcpClient socket)
     : base(socket)
 {
     JsonResolverStrategy resolver = new JsonResolverStrategy();
     _jsonIn = new JsonReader(new DataReaderSettings(resolver));
     _jsonOut = new JsonWriter(new DataWriterSettings(new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.CamelCase)));
 }
Пример #18
0
        public void handleMessage(Message msg)
        {

            if (msg is CardTypesMessage)
            {
                JsonReader jsonReader = new JsonReader();
                Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
                Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["cardTypes"];

                this.cardids = new int[d.GetLength(0)];
                this.cardnames = new string[d.GetLength(0)];
                this.cardImageid = new int[d.GetLength(0)];

                for (int i = 0; i < d.GetLength(0); i++)
                {
                    cardids[i] = Convert.ToInt32(d[i]["id"]);
                    cardnames[i] = d[i]["name"].ToString();
                    cardImageid[i] = Convert.ToInt32(d[i]["cardImage"]);
                }
                
                App.Communicator.removeListener(this);//dont need the listener anymore
            }
            
            return;
        }
Пример #19
0
 private void onReqChangeSuccess(BaseWWWRequest obj)
 {
     try
     {
         DestroyEquipData data = new JsonFx.Json.JsonReader().Read <DestroyEquipData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.onReqChangeFail(obj);
         }
         else
         {
             if (data.userVo != null)
             {
                 GameData.instance.UserInfo.UpdateResource(data.userVo);
             }
             if (data.detailInfo != null)
             {
                 GameData.instance.UserInfo.UpdateDetailInfo(data.detailInfo);
             }
             this.UpdateEquip();
             if (data.equipmentVo != null)
             {
                 GameData.instance.SetUserEquipments(data.equipmentVo);
             }
             this.OnDestroyEquipSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onReqChangeFail(obj);
     }
 }
Пример #20
0
        public string CreateJob(string jsondata)
        {
            var newjob = new WorkerJob();

            newjob.ID = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

            var jr = new JsonReader(jsondata);
            var jo = jr.Deserialize() as Dictionary<string, object>;

            if (jo.ContainsKey("callback"))
                newjob.CallbackUrl = jo["callback"].ToString();

            if (jo.ContainsKey("jobtype"))
                newjob.JobType = jo["jobtype"].ToString();

            // parse args...
            if (jo.ContainsKey("jobargs"))
                Utilities.FillArgsFromJson(newjob.JobArgs, jo["jobargs"]);

            newjob.MyUrl = "http://" + _worker.Config.Hostname + ":" + _worker.Config.Port;

            Console.WriteLine("WorkerJobController: Created job #" + newjob.ID + " with callback url " + newjob.CallbackUrl);

            m_jobs.Add(newjob);
            return newjob.ID;
        }
Пример #21
0
        public object Convert(int operation, string packet)
        {
            object _packet = null;
            UserOperation userOperation = (UserOperation)operation;

            JsonReader jsonReader = new JsonReader(packet);

            switch(userOperation)
            {
                case UserOperation.LOGIN:
                    _packet = jsonReader.Deserialize<LoginReply>();
                    break;
                case UserOperation.REGISTER:
                    _packet = jsonReader.Deserialize<RegisterReply>();
                    break;
                case UserOperation.CHARSELECT:
                case UserOperation.CREATECHAR:
                case UserOperation.DELETECHAR:
                case UserOperation.SELECTCHAR:
                    _packet = jsonReader.Deserialize<CharSelectPacket>();
                    break;
                default:
                    break;
            }

            return _packet;
        }
Пример #22
0
 public static T DeserializeUsingJSONFx<T> (string message)
 {
     object retMessage;
     var reader = new JsonFx.Json.JsonReader ();
     retMessage = reader.Read<T> (message);
     return (T)retMessage;
 }
Пример #23
0
 private void onReqSellSuccess(BaseWWWRequest obj)
 {
     try
     {
         SellModifyItemData data = new JsonFx.Json.JsonReader().Read <SellModifyItemData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.onReqSellFail(obj);
         }
         else
         {
             if (data.userResVo != null)
             {
                 GameData.instance.UserInfo.UpdateResource(data.userResVo);
             }
             if (data.packageVo != null)
             {
                 GameData.instance.UpdateUserItems(data.packageVo);
             }
             this.OnSellItemSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onReqModifyFail(obj);
     }
 }
Пример #24
0
        public void LoadData()
        {
            // Make sure it's time to update
            if( DateTime.Compare(nextUpdate, DateTime.UtcNow) == 1 ) {
                return;
            }

            nextUpdate = DateTime.UtcNow.AddHours(1);

            // Grab new data
            WebClient wc = new WebClient();

            try {
                wc.QueryString.Add("formatting", "1");

                String period = (String) mod.config.GetWithDefault("data-period", "1-day");
                String result = wc.DownloadString(new Uri("http://api.scrollspost.com/v1/prices/" + period));

                // Load it up
                List<APIPriceCheckResult> prices = new JsonReader().Read<List<APIPriceCheckResult>>(result);
                foreach( APIPriceCheckResult scroll in prices ) {
                    scrolls[scroll.card_id] = scroll;
                }

            } catch ( WebException we ) { // eeeeeeeeeeeeeeee
                App.Popups.ShowOk(this, "fail", "HTTP Error", "Unable to load pricing data, contact [email protected] for help.\n\n" + we.Message, "Ok");
                mod.WriteLog("Failed to load pricing data", we);
            }
        }
Пример #25
0
 internal void tryFectchErrorCode(BaseWWWRequest baseWWWRequest)
 {
     try
     {
         BasicResponse br = new JsonFx.Json.JsonReader().Read <BasicResponse>(this.UTF8String);
         if (br.eid != 0)
         {
             z.log("[错误]" + br.eidstring);
             if (br.eid == -411)
             {
                 z.log("[强制修复 ]" + br.eidstring + "战斗状态出错,主动回港。。。");
                 ServerRequestManager.instance.NotifyPVEBackHome();
             }
             if (br.eid == -9994 || br.eid == -9995 || br.eid == -9997)
             {
                 z.log("[登陆失效或已在别处登陆 ]" + br.eidstring + " 半小时内尝试重新登陆。。。");
                 ServerRequestManager.instance.NotifyRelogin();
             }
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
     }
 }
        public IDecoder GetDecoder()
        {
            var jsonReader = new JsonReader(new DataReaderSettings(DefaultEncoderDecoderConfiguration.CombinedResolverStrategy()
                , new TeamCityDateFilter()), new[] { "application/.*json", "text/.*json" });

            var readers = new List<IDataReader> { jsonReader };
            var dataReaderProvider = new RegExBasedDataReaderProvider(readers);
            return new DefaultDecoder(dataReaderProvider);
        }
Пример #27
0
 private void LoadShipConfigs()
 {
     if (this.shipConfigs != null)
     {
         AllConfigs configs = new JsonFx.Json.JsonReader().Read <AllConfigs>(this.shipConfigs);
         AllShipConfigs.instance.setShips(configs.shipCard);
         ServerRequestManager.instance.OnLoadConfigsComplete();
     }
 }
Пример #28
0
        public static IRestResponse<dynamic> ExecuteDynamic(this IRestClient client, IRestRequest request)
        {
            var response = client.Execute<dynamic>(request);

            dynamic content = new JsonReader().Read(response.Content);
            response.Data = content;

            return response;
        }
Пример #29
0
 private void LoadShipConfigs()
 {
     if (this.shipConfigs != null)
     {
         AllConfigs configs = new JsonFx.Json.JsonReader().Read<AllConfigs>(this.shipConfigs);
         AllShipConfigs.instance.setShips(configs.shipCard);
         ServerRequestManager.instance.OnLoadConfigsComplete();
     }
 }
Пример #30
0
    public override T Deserialize <T>(string text)
    {
        var r   = new JsonFx.Json.JsonReader();
        var s   = Environment.TickCount;
        var ret = r.Read <T>(text);

        DeserializeTimeList.Add(Environment.TickCount - s);
        return(ret);
    }
Пример #31
0
        public static bool tryUpdate()
        {
            WebClientTimeOut client = new WebClientTimeOut ();
            String versionMessageRaw;
            try {
                versionMessageRaw = client.DownloadString (new Uri("http://mods.scrollsguide.com/version"));
            } catch (WebException) {
                return false;
            }

            JsonReader reader = new JsonReader ();
            VersionMessage versionMessage = (VersionMessage)reader.Read (versionMessageRaw, typeof(VersionMessage));

            int version = versionMessage.version ();
            String installPath = Platform.getGlobalScrollsInstallPath () + Path.DirectorySeparatorChar + "ModLoader" + Path.DirectorySeparatorChar;

            try {
                File.Delete (installPath + "Updater.exe");
            } catch {}

            if (!System.IO.Directory.Exists(installPath)) {
                System.IO.Directory.CreateDirectory(installPath);
            }

            if (version > ModLoader.getVersion()) {

                byte[] asm;
                try {
                    asm = client.DownloadData(new Uri("http://mods.scrollsguide.com/download/update"));
                } catch (WebException) {
                    return false;
                }
                File.WriteAllBytes (installPath + "Updater.exe", asm);
                if (CheckToken (installPath + "Updater.exe", token)) {

                    try {
                        App.Popups.ShowInfo ("Scrolls Summoner is updating", "Please wait while the update is being downloaded");
                        Dialogs.showNotification("Scrolls Summoner is updating", "Please wait while the update is being downloaded");
                    } catch { }

                    if (Platform.getOS () == Platform.OS.Win) {
                        new Process { StartInfo = { FileName = installPath + "Updater.exe", Arguments = "" } }.Start ();
                    } else if (Platform.getOS () == Platform.OS.Mac) {
                        Assembly.LoadFrom (installPath + "Updater.exe").EntryPoint.Invoke (null, new object[] { new string[] {} });
                    }
                    return true;
                }

                try {
                    App.Popups.KillCurrentPopup();
                } catch {}
            }

            return false;
        }
Пример #32
0
 /// <summary>
 /// Deserialize the specified message using either JSONFX or NEWTONSOFT.JSON.
 /// The functionality is based on the pre-compiler flag
 /// </summary>
 /// <param name="message">Message.</param>
 public static T Deserialize<T> (string message)
 {
     object retMessage;
     #if (USE_JSONFX)
     var reader = new JsonFx.Json.JsonReader();
     retMessage = reader.Read<T>(message);
     #else
     retMessage = JsonConvert.DeserializeObject<T> (message);
     #endif
     return (T)retMessage;
 }
        public IDecoder GetDecoder()
        {
            var jsonReader = new JsonReader(new DataReaderSettings(CombinedResolverStrategy()), new[] { "application/.*json", "text/.*json" });
            var xmlReader = new XmlReader(new DataReaderSettings(CombinedResolverStrategy()),
                                          new[] {"application/.*xml", "text/.*xhtml", "text/xml", "text/html"});

            var readers = new List<IDataReader> {jsonReader, xmlReader};

            var dataReaderProvider = new RegExBasedDataReaderProvider(readers);

            return new DefaultDecoder(dataReaderProvider);
        }
Пример #34
0
    private void onSuccess(BaseWWWRequest obj)
    {
        try
        {
            AllConfigs configs;
            if (this.needZip)
            {
                configs = new JsonFx.Json.JsonReader().Read <AllConfigs>(base.UTF8String);
            }
            else
            {
                configs = new JsonFx.Json.JsonReader().Read <AllConfigs>(this.UTF8String);
            }
            if (configs.eid != 0)
            {
                this.onFail(obj);
            }
            else
            {
                z.log("setShips");
                AllShipConfigs.instance.setShips(configs.shipCard);
                z.log("shipCard");
                GameConfigs.instance.PrepareEquipmentConfigs(configs.shipEquipment);
                z.log("PrepareEquipmentConfigs");
                GameConfigs.instance.PreparePVEExploreLevels(configs.pveExplore);
                z.log("PreparePVEExploreLevels");
                GameConfigs.instance.SetShopItems(configs.shipShop);
                GameConfigs.instance.SetShipEvoItems(configs.shipItem);
                GameConfigs.instance.SetSkillConfigs(configs.shipSkill);
                z.log("SetSkillConfigs");
                GameConfigs.instance.SetBuffConfigs(configs.shipSkillBuff);
                GameConfigs.instance.GlobalConfig     = configs.globalConfig;
                GameConfigs.instance.marketingConfigs = configs.marketingConfigs;
                z.log("marketingConfigs");
                PVEConfigs.instance.SetCampaignChapters(configs.shipCampaign);
                PVEConfigs.instance.SetCampaignLevels(configs.shipCampaignLevel);
                GameConfigs.instance.errCode = configs.errorCode;

                //if (this.testShipUpdate && (this.shipUpdateconfigs != null))
                //{
                //    UpdateConfigs configs2 = JsonReader.Deserialize<UpdateConfigs>(this.shipUpdateconfigs.text);
                //    UpdateManager.Instance.SetShips(configs2.ships);
                //}

                ServerRequestManager.instance.OnLoadConfigsComplete();
            }
        }
        catch (Exception e)
        {
            z.log(e.Message + "  " + e.StackTrace);
            this.onFail(obj);
        }
    }
 public PresetData Load(string fileName) {
     // ファイル読み込み
     try {
         using (FileStream fs = File.OpenRead(fileName))  {
             var reader = new JsonFx.Json.JsonReader(fs);
             return (PresetData)reader.Deserialize(typeof(PresetData));
         }
     } catch(Exception e) {
         LogUtil.Log("ACCプリセットの読み込みに失敗しました", e);
         return null;
     }
 }
Пример #36
0
    public static dynamic StringToDynamic(string s)
    {
        if ("" == s)
        {
            return(null);
        }

        JsonFx.Json.JsonReader cReader = new JsonFx.Json.JsonReader();
        dynamic c = cReader.Read(s);

        return(c);
    }
Пример #37
0
    private void onSuccess(BaseWWWRequest obj)
    {
        try
        {
            AllConfigs configs;
            if (this.needZip)
            {
                configs = new JsonFx.Json.JsonReader().Read<AllConfigs>(base.UTF8String);
            }
            else
            {
                configs = new JsonFx.Json.JsonReader().Read<AllConfigs>(this.UTF8String);
            }
            if (configs.eid != 0)
            {
                this.onFail(obj);
            }
            else
            {
                z.log("setShips");
                AllShipConfigs.instance.setShips(configs.shipCard);
                z.log("shipCard");
                GameConfigs.instance.PrepareEquipmentConfigs(configs.shipEquipment);
                z.log("PrepareEquipmentConfigs");
                GameConfigs.instance.PreparePVEExploreLevels(configs.pveExplore);
                z.log("PreparePVEExploreLevels");
                GameConfigs.instance.SetShopItems(configs.shipShop);
                GameConfigs.instance.SetShipEvoItems(configs.shipItem);
                GameConfigs.instance.SetSkillConfigs(configs.shipSkill);
                z.log("SetSkillConfigs");
                GameConfigs.instance.SetBuffConfigs(configs.shipSkillBuff);
                GameConfigs.instance.GlobalConfig = configs.globalConfig;
                GameConfigs.instance.marketingConfigs = configs.marketingConfigs;
                z.log("marketingConfigs");
                PVEConfigs.instance.SetCampaignChapters(configs.shipCampaign);
                PVEConfigs.instance.SetCampaignLevels(configs.shipCampaignLevel);
                GameConfigs.instance.errCode = configs.errorCode;

                //if (this.testShipUpdate && (this.shipUpdateconfigs != null))
                //{
                //    UpdateConfigs configs2 = JsonReader.Deserialize<UpdateConfigs>(this.shipUpdateconfigs.text);
                //    UpdateManager.Instance.SetShips(configs2.ships);
                //}

                ServerRequestManager.instance.OnLoadConfigsComplete();
            }
        }
        catch (Exception e)
        {
            z.log(e.Message+ "  " + e.StackTrace);
            this.onFail(obj);
        }
    }
Пример #38
0
    public void ReadSettings()
    {
        var filePath = new System.IO.FileInfo(ServerDirectory.FullName + "/Server.json");

        if (!filePath.Exists)
        {
            Log.Info("No Server.json, using only commandline args");
            return;
        }
        try
        {
            var txt        = System.IO.File.ReadAllText(filePath.FullName);
            var reader     = new JsonFx.Json.JsonReader();
            var dictionary = (Dictionary <string, object>)reader.Read(txt);

            object[] pluginDirsList = new object[0];
            TryGetValue(dictionary, "PluginsDir", ref pluginDirsList);
            foreach (object dir in pluginDirsList)
            {
                if (dir is string)
                {
                    Log.Debug($"Adding plugin directory: {dir}");
                    pluginDirs.Add(new System.IO.DirectoryInfo((string)dir));
                }
                else
                {
                    Log.Info($"PluginsDir included value that was not a string: {dir}");
                }
            }

            object[] pluginsList = new object[0];
            TryGetValue(dictionary, "Plugins", ref pluginsList);
            foreach (object dir in pluginsList)
            {
                if (dir is string)
                {
                    Log.Debug($"Adding plugin: {dir}");
                    directPluginDirs.Add(new System.IO.FileInfo((string)dir));
                }
                else
                {
                    Log.Info($"Plugins included value that was not a string: {dir}");
                }
            }

            Log.Info("Loaded settings from Server.json");
        }
        catch (Exception e)
        {
            Log.Error($"Couldn't read Server.json. Is your json malformed?\n{e}");
        }
    }
Пример #39
0
 public PresetData Load(string fileName)
 {
     // ファイル読み込み
     try {
         using (FileStream fs = File.OpenRead(fileName))  {
             var reader = new JsonFx.Json.JsonReader(fs);
             return((PresetData)reader.Deserialize(typeof(PresetData)));
         }
     } catch (Exception e) {
         LogUtil.Log("ACCプリセットの読み込みに失敗しました", e);
         return(null);
     }
 }
Пример #40
0
 public ExportationOptions CreateSettings()
 {
     ExportationOptions result = new ExportationOptions();
     string apath = Application.dataPath.Replace("/Assets", "");
     string ufile = Path.Combine(apath, "UnityBabylonOptions.ini");
     if (File.Exists(ufile))
     {
         var readText = File.ReadAllText(ufile);
         var jsReader = new JsonReader();
         result = jsReader.Read<ExportationOptions>(readText);
     }
     return result;
 }
Пример #41
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="rawResponse"></param>
    /// <returns></returns>
    public static MatchIDList fromJSON(object rawResponse)
    {
        if (rawResponse is String)
        {
            String json = (String)rawResponse;
            JsonFx.Json.JsonReader reader = JSONUtils.getJsonReader(json);
            long[] matchArray             = reader.Deserialize <long[]>();

            return(new MatchIDList(new List <long>(matchArray)));
        }

        return(new MatchIDList());
    }
Пример #42
0
        public void Encode()
        {
            var id = new InstrumentData() { Pitch = 31, Roll = 89 };

            var x = new JsonWriter();
            var js = x.Write(id);

            var y = new JsonReader();
            var decoded = y.Read<InstrumentData>(js);

            Assert.AreEqual(id.Roll, decoded.Roll);
            Assert.AreEqual(id.Pitch, decoded.Pitch);
        }
Пример #43
0
        public static JsonPatchDocument Read(TextReader r)
        {
            JsonPatchDocument patch = new JsonPatchDocument();

              JsonReader jsr = new JsonReader();
              CompleteOperation[] operations = null;
              try
              {
            operations = jsr.Read<CompleteOperation[]>(r);
              }
              catch (DeserializationException ex)
              {
            throw new JsonPatchParserException(ex.Message, ex);
              }

              foreach (CompleteOperation operation in operations)
              {
            try
            {
              switch (operation.op)
              {
            case "add":
              patch.Add(operation.path, operation.value);
              break;
            case "remove":
              patch.Remove(operation.path);
              break;
            case "replace":
              patch.Replace(operation.path, operation.value);
              break;
            case "move":
              patch.Move(operation.from, operation.path);
              break;
            case "copy":
              patch.Copy(operation.from, operation.path);
              break;
            case "test":
              patch.Test(operation.path, operation.value);
              break;
            case null:
              throw new JsonPatchParserException("No 'op' property found.");
              }
            }
            catch (ArgumentNullException ex)
            {
              throw new JsonPatchParserException(string.Format("Missing parameter '{0}' for op:'{1}'.", ex.ParamName, operation.op), ex);
            }
              }

              return patch;
        }
Пример #44
0
        // Logging an account in
        public void AccountLogin(object password)
        {
            App.Popups.ShowInfo("ScrollsPost Login", "Logging in, this will only take a second...");

            WebClient wc = new WebClient();

            try {
                NameValueCollection form = new NameValueCollection();
                form["email"] = config.GetString("email");
                form["password"] = (String) password;
                form["id"] = App.MyProfile.ProfileInfo.id;
                form["uid"] = App.MyProfile.ProfileInfo.userUuid;
                form["name"] = App.MyProfile.ProfileInfo.name;

                byte[] bytes = wc.UploadValues(new Uri(mod.apiURL + "/v1/user"), "PUT", form);
                Dictionary<String, object> result = new JsonReader().Read<Dictionary<String, object>>(Encoding.UTF8.GetString(bytes));

                // Failed to login
                if( result.ContainsKey("errors") ) {
                    Dictionary<String, object> errors = (Dictionary<String, object>) result["errors"];
                    if( errors.ContainsKey("password") ) {
                        ShowAuthPassword(false, "<color=red>Password " + ((String[]) errors["password"])[0] + "</color>");
                    } else if( errors.ContainsKey("email") ) {
                        ShowAuthEmail("<color=red>Email " + ((String[]) errors["email"])[0] + "</color>");
                    }

                    // Save our keys so we don't store passwords
                } else {
                    App.Popups.ShowOk(this, "done", "Logged In!", "You're now logged into your ScrollsPost.com account!\n\nYour collection will automatically sync to ScrollsPost now, will let you know when the initial sync has finished in-game.", "Ok");

                    config.Add("user-id", (String) result["user_id"]);
                    config.Add("api-key", (String) result["api_key"]);
                    config.Remove("email");
                    config.Remove("last-card-sync");

                    if( result.ContainsKey("verif_key") ) {
                        config.Add("verif-key", (String) result["verif_key"]);
                    }

                    //if( config.ContainsKey("verif-key") ) {
                    //    verifier = new AccountVerifier(config);
                    //}

                    App.Communicator.sendRequest(new LibraryViewMessage());
                }

            } catch ( WebException we ) {
                App.Popups.ShowOk(this, "fail", "HTTP Error", "Unable to login due to an HTTP error.\nContact [email protected] for help.\n\n" + we.Message, "Ok");
                mod.WriteLog("Failed to register", we);
            }
        }
Пример #45
0
    public static ChampionMastery[] fromJSONArray(object rawResponse)
    {
        if (rawResponse is String)
        {
            String json = (String)rawResponse;
            JsonFx.Json.JsonReader reader = JSONUtils.getJsonReader(json);

            ChampionMastery[] championMasteryList = reader.Deserialize <ChampionMastery[]>();

            return(championMasteryList);
        }

        return(null);
    }
Пример #46
0
        public void IgnoreMutilineComments()
        {
            var input = "/*comment1\r\ncomment2\r\ncomment3*/\r\n{ \"Bars\": [{\"Baz\": \"Test\"}]}";
            var expected = new Foo2
            {
                Bars = new List<Bar2>
                {
                    new Bar2 { Baz="Test"}
                }
            };

            var actual = new JsonReader().Read<Foo2>(input);

            Assert.Equal(expected, actual);
        }
Пример #47
0
    /// <summary>
    /// Team information
    /// </summary>

    /*public List<Team> Teams
     * {
     *  get
     *  {
     *      return this.teams;
     *  }
     *  set
     *  {
     *      this.teams = value;
     *  }
     * }*/

    /// <summary>
    /// Match timeline data (not included by default)
    /// </summary>

    /*public Timeline timeline
     * {
     *  get
     *  {
     *      return this.timeline;
     *  }
     *  set
     *  {
     *      this.timeline = value;
     *  }
     * }*/

    #endregion

    /// <summary>
    ///
    /// </summary>
    /// <param name="rawResponse"></param>
    /// <returns></returns>
    public static MatchDetail fromJSON(object rawResponse)
    {
        if (rawResponse is String)
        {
            String json = (String)rawResponse;
            JsonFx.Json.JsonReader reader = JSONUtils.getJsonReader(json);

            MatchDetail matchDetail = new MatchDetail();
            matchDetail = reader.Deserialize <MatchDetail>();

            return(matchDetail);
        }

        return(new MatchDetail());
    }
Пример #48
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="rawResponse"></param>
    /// <returns></returns>
    public static ChampionDB fromJSON(object rawResponse)
    {
        if (rawResponse is String)
        {
            String json = (String)rawResponse;
            JsonFx.Json.JsonReader reader = JSONUtils.getJsonReader(json);

            ChampionDB championDB = new ChampionDB();
            championDB = reader.Deserialize <ChampionDB>();

            return(championDB);
        }

        return(new ChampionDB());
    }
Пример #49
0
    public static Summoner fromJSON(object rawResponse)
    {
        if (rawResponse is String)
        {
            String json = (String)rawResponse;
            JsonFx.Json.JsonReader reader = JSONUtils.getJsonReader(json);

            Summoner summoner = new Summoner();
            summoner = reader.Deserialize <Summoner>();

            return(summoner);
        }

        return(new Summoner());
    }
Пример #50
0
        void UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message, "Error", MessageBoxButton.OK);
                return;
            }
            var reader =
                new JsonReader(
                    new DataReaderSettings(
                        new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.PascalCase)));

            var result = reader.Read<RunResult>(e.Result);
            _codeEditorViewModel.Output = !string.IsNullOrEmpty(result.CompileError) ? result.CompileError : result.Output;
            _codeEditorViewModel.IsRunning = false;
        }
Пример #51
0
        private static string SendPassword(string username, string encryptedBase64, Dictionary<string, object> loginParams)
        {
            // Send the RSA-encrypted password via POST.
            var webRequest = WebRequest.Create(API_DO_LOGIN) as HttpWebRequest;
            webRequest.Method = "POST";

            var timestamp = loginParams["timestamp"] as string;

            var fields = new NameValueCollection();
            fields.Add("username", username);
            fields.Add("password", encryptedBase64);
            fields.Add("emailauth", String.Empty);
            fields.Add("captchagid", String.Empty);
            fields.Add("captcha_text", String.Empty);
            fields.Add("emailsteamid", String.Empty);
            fields.Add("rsatimestamp", timestamp);

            var query = fields.ConstructQueryString();
            var queryData = Encoding.ASCII.GetBytes(query);

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.ContentLength = queryData.Length;
            webRequest.CookieContainer = new CookieContainer();

            // Write the request
            using (Stream stream = webRequest.GetRequestStream())
            {
                stream.Write(queryData, 0, queryData.Length);
            }

            // Perform the request
            var response = webRequest.GetResponse() as HttpWebResponse;

            String res;
            using (Stream stream = response.GetResponseStream())
            {
                res = stream.ReadAll();
            }

            response.Close();

            var reader = new JsonReader();
            var results = reader.Read<Dictionary<string, object>>(res);

            return response.Cookies["steamLogin"].Value;
        }
Пример #52
0
        /// <summary>
        /// Deserialize the specified message using either JSONFX or NEWTONSOFT.JSON.
        /// The functionality is based on the pre-compiler flag
        /// </summary>
        /// <param name="message">Message.</param>
        public static T Deserialize <T> (string message)
        {
            object retMessage;

                                                #if (USE_JSONFX) || (USE_JSONFX_UNITY)
            var reader = new JsonFx.Json.JsonReader();
            retMessage = reader.Read <T> (message);
                                                #elif (USE_JSONFX_UNITY_IOS)
            UnityEngine.Debug.Log("message: " + message);
            retMessage = JsonReader.Deserialize <T>(message);
                                                #elif (USE_MiniJSON)
            UnityEngine.Debug.Log("message: " + message);
            retMessage = Json.Deserialize(message) as object;
                                                #else
            retMessage = JsonConvert.DeserializeObject <T> (message);
                                                #endif
            return((T)retMessage);
        }
Пример #53
0
        void OnGUI()
        {
            if (exportationOptions == null)
            {
                exportationOptions = new ExportationOptions();

                if (File.Exists("Unity3D2Babylon.ini"))
                {
                    var readText = File.ReadAllText("Unity3D2Babylon.ini");
                    var jsReader = new JsonReader();
                    exportationOptions = jsReader.Read<ExportationOptions>(readText);
                }
            }

            GUILayout.Label("Exportation options", EditorStyles.boldLabel);
            exportationOptions.ReflectionDefaultLevel = EditorGUILayout.Slider("Reflection default level", exportationOptions.ReflectionDefaultLevel, 0, 1.0f);

            GUILayout.Label("Collisions options", EditorStyles.boldLabel);
            exportationOptions.ExportCollisions = EditorGUILayout.Toggle("Collisions", exportationOptions.ExportCollisions);
            exportationOptions.CameraEllipsoid = EditorGUILayout.Vector3Field("Camera's Ellipsoid:", exportationOptions.CameraEllipsoid);
            exportationOptions.Gravity = EditorGUILayout.Vector3Field("Gravity:", exportationOptions.Gravity);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (GUILayout.Button("Export"))
            {
                Export();
            }

            EditorGUILayout.Space();

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            foreach (var log in logs)
            {
                var bold = log.StartsWith("*");

                GUILayout.Label(bold ? log.Remove(0, 1) : log, bold ? (EditorStyles.boldLabel) : EditorStyles.label);
            }
            EditorGUILayout.EndScrollView();

            Repaint();
        }
Пример #54
0
    private void updateDrop(string nodename, bool viewbywintype)
    {
        try
        {

            var response = p.GetAsync(tools.helper.count_server_addr + "/analyze/" + (viewbywintype ? "weapon/weapon_" : "ship/ship_") + nodename + ".json").Result;
            response.EnsureSuccessStatusCode();

            var content = response.Content.ReadAsByteArrayAsync().Result;
            string ss = System.Text.Encoding.UTF8.GetString(content);
            NodeDrop list = new JsonFx.Json.JsonReader().Read<NodeDrop>(ss);

            GridPanel panel = droplist.PrimaryGrid;
            panel.Rows.Clear();
            int totalcount = 0;
            foreach (var cl in list.nodeval)
            {
                totalcount += cl.count;
            }
            float t = (float)totalcount;

            foreach (var cl in list.nodeval)
            {
                object[] vals = new object[6];

                vals[0] = cl.name;
                vals[1] = cl.count;
                float c = (float)cl.count;
                vals[2] = "" + (c * 100.0f / t) + "%";

                GridRow gr = new GridRow(vals);
                panel.Rows.Add(gr);
                gr.RowHeight = 20;

            }

        }
        catch (Exception)
        {

        }
    }
Пример #55
0
 private void startRepairSuccess(BaseWWWRequest obj)
 {
     try
     {
         StartRepairData data = new JsonFx.Json.JsonReader().Read <StartRepairData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.startRepairFail(obj);
             z.log("[少女开始泡澡失败] 请使用正确脱衣姿势 ");
         }
         else
         {
             UserInfo ui            = GameData.instance.UserInfo;
             int      oilcost       = ui.oil - data.userVo.oil;
             int      ammocost      = ui.ammo - data.userVo.ammo;
             int      steelcost     = ui.steel - data.userVo.steel;
             int      aluminiumcost = ui.aluminium - data.userVo.aluminium;
             z.log("[少女成功开始泡澡] 实际资源消耗: "
                   + (oilcost > 0 ?("油 - " + oilcost):"")
                   + (ammocost > 0 ? ("弹 - " + ammocost) : "")
                   + (steelcost > 0 ? ("钢 - " + steelcost) : "")
                   + (aluminiumcost > 0 ? ("铝 - " + aluminiumcost) : "")
                   );
             if (data.userVo != null)
             {
                 GameData.instance.UserInfo.UpdateResource(data.userVo);
             }
             if (data.repairDockVo != null)
             {
                 GameData.instance.SetRepairDocks(data.repairDockVo);
             }
             this.OnStartRepairShipSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.startRepairFail(obj);
     }
 }
Пример #56
0
 private void onSMultiSuccess(BaseWWWRequest obj)
 {
     try
     {
         SupplyAllShipData data = new JsonFx.Json.JsonReader().Read <SupplyAllShipData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.onSMultiFail(obj);
         }
         else
         {
             if (data.shipVO != null)
             {
                 GameData instance = GameData.instance;
                 foreach (UserShip ship in data.shipVO)
                 {
                     instance.UpdateUserShip(ship);
                 }
             }
             if (data.userVo != null)
             {
                 var ui = GameData.instance.UserInfo;
                 z.log("[补给舰队成功] 少女吃喝完毕... 消耗 "
                       + " 油 - " + (ui.oil - data.userVo.oil)
                       + " 弹 - " + (ui.ammo - data.userVo.ammo)
                       + " 钢 - " + (ui.steel - data.userVo.steel)
                       + " 铝 - " + (ui.aluminium - data.userVo.aluminium)
                       );
                 GameData.instance.UserInfo.UpdateResource(data.userVo);
             }
             this.OnSupplyMultiSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onSMultiFail(obj);
     }
 }
        protected override void OnMessage(MessageEventArgs e)
        {
            var reader = new JsonReader();
            KSPACPackets message = reader.Read<KSPACPackets>(e.Data);
            if (message != null)
            {
                switch (message.t)
                {
                    case 1:
                        ConnectionRequest connReqPacket = reader.Read<ConnectionRequest>(e.Data);

                        Send(connReqPacket.HandlePacket(WSClient.getClient(ID)));
                        break;
                    case 2:
                        ActiveVesselThrottleChange throtChg = reader.Read<ActiveVesselThrottleChange>(e.Data);
                        throtChg.HandlePacket(WSClient.getClient(ID));
                        break;
                    case 3:
                        new ActivateNextStage().HandlePacket(WSClient.getClient(ID));
                        break;
                    case 4:
                        RequestAllVesselData ravd = reader.Read<RequestAllVesselData>(e.Data);
                        Send(ravd.HandlePacket(WSClient.getClient(ID)));
                        break;
                    case 5:
                        // Tis an event
                        ChangeSubscriptionToEvent cste = reader.Read<ChangeSubscriptionToEvent>(e.Data);
                        String sendData = cste.HandlePacket(WSClient.getClient(ID));
                        if (sendData != "") Send(sendData);
                        break;
                    case 6:
                        GetCrossOriginHTML gcoh = reader.Read<GetCrossOriginHTML>(e.Data);
                        gcoh.HandlePacket(WSClient.getClient(ID));
                        break;
                    default:
                        Send(new UnrecognizedCommand(message.t).toJson());
                        break;
                }
            }
        }
Пример #58
0
    private void updateDrop(string nodename, bool viewbywintype)
    {
        try
        {
            var response = p.GetAsync(tools.helper.count_server_addr + "/analyze/" + (viewbywintype ? "weapon/weapon_" : "ship/ship_") + nodename + ".json").Result;
            response.EnsureSuccessStatusCode();

            var      content = response.Content.ReadAsByteArrayAsync().Result;
            string   ss      = System.Text.Encoding.UTF8.GetString(content);
            NodeDrop list    = new JsonFx.Json.JsonReader().Read <NodeDrop>(ss);


            GridPanel panel = droplist.PrimaryGrid;
            panel.Rows.Clear();
            int totalcount = 0;
            foreach (var cl in list.nodeval)
            {
                totalcount += cl.count;
            }
            float t = (float)totalcount;


            foreach (var cl in list.nodeval)
            {
                object[] vals = new object[6];

                vals[0] = cl.name;
                vals[1] = cl.count;
                float c = (float)cl.count;
                vals[2] = "" + (c * 100.0f / t) + "%";

                GridRow gr = new GridRow(vals);
                panel.Rows.Add(gr);
                gr.RowHeight = 20;
            }
        }
        catch (Exception)
        {
        }
    }
Пример #59
0
 private void onGetLogReqSuccess(BaseWWWRequest obj)
 {
     try
     {
         GetLogData data = new JsonFx.Json.JsonReader().Read <GetLogData>(this.UTF8String);
         base.responseData = data;
         if (data.eid != 0)
         {
             this.onGetLogReqFail(obj);
         }
         else
         {
             GameData.instance.ShipBuildLogs = data.log;
             this.OnGetLogSuccess(EventArgs.Empty);
         }
     }
     catch (Exception exception)
     {
         z.log(exception.Message);
         this.onGetLogReqFail(obj);
     }
 }
Пример #60
0
        void ListDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null && !string.IsNullOrEmpty(e.Result))
            {
                var reader = new JsonReader();

                var result = reader.Read<IEnumerable<string>>(e.Result);
                PopulateMainListBox(result);
            }
            else
            {
                var localFiles = e.UserState as string[];
                if (localFiles != null && localFiles.Length > 0)
                {
                    PopulateMainListBox(localFiles);
                }
                else
                {
                    MessageBox.Show("No Saved code was found.");
                    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                }
            }
        }