How to update the data table on client side.(iOS MMO game) - ios

Currently I'm developing an iOS MMO game using cocos2d-x. The game uses many data tables (excel files) which are created by the designer. These tables contains such numbers as how much gold(crystal, etc..) will be needed for upgrading a barrack.
My question is, is that how to update that tables once if the tables have been modified on the server side?
My option: Use SQLite to store table on client side, once the tables has been modified on server side, the server will parse the tables (excel files) and send the data in JSON format.
then the client parse the JSON string and save that data to SQLite file.
Is there any better way? I find that some game stores CSV files on client side, how do they update those CSV files?

How you store the data (and in which format) is entirely up to you, although the framework does provide some helper classes (checkout ccUserDefault). The simplest way to check whethere data files on the client side are up to date is to checksum them (either apply a checksum to the data stored in the file or on the whole file itself). So to check for sync, the server side app applies a checksum to the data and so does the client (using the same algorithm, of course ;) ) and the numbers are compared; if they match, the data is in sync.
This is arguably more reliable if the server-side app generates the data files and sends them down, rather than relying on the client-side app to do it. But as long as the server knows how to generate data files using the same method that the client does, then the success of the client's file generation process can always be verified using this same checksum method.

Related

How to avoid parsing data fetched from database to dynamically create forms?

My application deserializes XML that is stored in a CLOB column in Oracle database to dynamically create forms. This approach allows relatively easy update deployment, but is too slow when a user connects through a VPN using e.g. 3G network.
I wonder is there a way to store those objects (forms) on the users's file system so that no parsing is needed?
I don't have any code to show but I hope this question is scoped narrowly enough to be acceptable.
My suggestion:
Make sure your form(s) is saved to the database in binary form, not as a text representation.
In your client app, request the CLOB column data from the DB and save it to a TMemoryStream. Then, you can instantiate the form by loading it from the TMemoryStream and it doesn't need to go near the file system on the client side. That way, no parsing of the Form data from the db is necessary.
The accepted answer to this q shows how to read a form from a memory stream - see the call to MemStream.ReadComponent et seq. Obviously, using tje method in that q, the CLOB data should have been created using the memorystream steps of its SaveComponentToFile.

Binding a irregular URL encoded POST request with Nancy

I'm supposed to make an old sqlite database editable trough a Sketchup Plugin in its WebDialog. Sketchups Ruby is not able to install the sqlite3 gem and since I already need to display the table in a WebDialog, I opted for a micro service with the help of Nancy. The existing Plugin already uses the dhtmlxSuite and its Grid Component is exactly what I need. They even offer a Connector that can send requests based on the actions of the user in the grid.
They also offer a connector for the server side, but that too does not work with sqlite. I already managed to connect to my database, used Dapper to bin the result of an SQL query to an object and return that data with a manually crafted JSON object. Very hacky, but it populates the data successful.
Now the client-Connector sends data manipulated by the user (delete and insert is forbidden) back with an url encoded POST request that looks quite weird:
4_gr_id=4&4_c0=0701.041&4_c1=Diagonale%20f%3Fr%202.07%20X%201.50%20m&4_c2=AR&4_c3=8.3&4_c4=380&4_c5=38.53&4_c6=0&4_c7=0&4_!nativeeditor_status=updated&ids=4
I'm not sure exactly why the hell they would use the row index inside the key for the key-value pairs, but this just makes my life that much harder. The only thing that comes to my mind is extracting the data I'm interested in with a regex, but that sounds even worse than what I did before.
Any suggestions for me how I could map that POST request to something usable?

How does the Parse Local Database store its data?

Is it using core data?
Is the data encrypted in any way? Is there a way a user could maliciously modify it easily?
I have been trying to look for this answer since LDB was announced for iOS, and have not found any information regarding this other than 'it is just like our android implementation'. If this information is stored in plaintext I cannot store sensitive information in it, which is why I would like to know.
I've just created an app that uses the local database, and here's what I've found.
Inside <app sandbox directory>/Library/Private Documents/Parse there is a file called ParseOfflineStore. This is a sqlite database. There are 2 relevant tables inside (ParseObjects and Dependencies), and pinned objects are stored inside ParseObjects.
To answer your questions:
1) No, it does not use CoreData, but it is sqlite (the same db backing store as CoreData).
2) No, it is not encrypted. It's in the clear, stored in the ParseObjects table, in the json column as cleartext json.
It would be relatively trivial for anyone who can hook up iExplorer to the app to download, change, and upload the local database. However, if you have a user who can do that, it's likely they could proxy your app with Charles anyway ;-)

Update iOS database via file or via json?

I'm currently updating an app which I developed quite a long time ago. I'm wondering what's the best way to update the sqlite database via REST api.
I'm thinking about the following process:
When the user is opening the app the device will send the current database version (locally stored in a .plist) to a REST webservice.
The webservice compares the client version to the web version - if there is a new one available I would like to send the entire database to the client (no delta updates).
Now I'm thinking what's the better way to "send" the data to the client. Download a sqlite? Or create a JSON at the webservice (what means somehow overhead). The sqlite is currently about 100 kb.
Anyone an idea?
If
there is no user data to preserve and there won't be any in the future, e.g. if your database is completely static
it is safe to assume its size is not going to increase significantly
your database model hasn't changed and is highly unlikely to change in the future
you're 86% sure that you'll never again be requiring a proper api to a similar online database, featuring delta updates and a generic format like json
go ahead and transmit that replacement sqlite. Otherwise, do it properly!

Updating Sqlite from web server?

I am currently building an iPhone app that is using Core Data and sqlite databases where the user will be reading static information from the database throughout the app. I have the issue where we may update the information in the database but not want to do a full update of the app, just the database. Can someone please help me out with either a easy function or a tutorial of how to go to a website or server and download the file which will replace the database that we have already put into the app? I'm new in xcode and I`m doing my first app.... thanks for your help
I think what would be a good idea is for your website to publish the data that must be stored in sqllite over REST, possibly in JSON or XML format.
This blog post describes how you could do just that. I must say that its approach to retrieving the content from the webservice is kind of low-level but it'll get the job done. Maybe RestKit can help you take care of all the low-level networking/http stuff.
I assume you want the static data locally so you don't require a constant internet connection for your app to work. Another option is to request the static data from the web and persist it in a file (NSUserDefaults etc...). But, that depends on how complicated the static data is and whether you have to query into that data. If you need to issue queries on that static data, a DB is definitely better.
You can also do a combination where you download updated DB if available async while your app works. You could have a setting in user defaults which is the current static data DB. If updated, you switch the current setting and re-establish the DB connection under a lock.
Here's how to make an http request using iOS.
rest web services in iphone
If you're downloading db data, don't convert the NSData to a string like in that sample ...
Also, ASI-HTTP-Request is popular. Here's samples on how to download a file:
http://allseeing-i.com/ASIHTTPRequest/How-to-use
http://www.cocoadev.com/index.pl?NSUserDefaults

Resources