Is there any way of changing parameters of websocket without ending connection? - ios

My app has coin infos in its table view cell which has 40 cell. I have faced a problem by connecting to the server via websocket. It has been updated its every cell on the tableview continuously therefore in my opinion it hasn't become a useful method to me because of my future plans of adding much more coins to the app which can turn in to be a bigger problem for me in the future. I would like to update the coins which are on the screen but not the ones which are not on the screen. In other words, I would like to update parameters of websocket without end connection. I searched for the graphQL subscription system but I'm not sure about the system which would it be helpful. What are your suggestions for me?
Thank you for your help.

Related

Updating tableview with UIRefresh

The title of my question makes this look like a duplicate, but it's much more complicated of an issue than the title suggests, so please read through this post before marking it as a duplicate.
I have a tableview that uses UIRefresh for pull-to-refresh. When the tableview refreshes, it gets info from CloudKit. As the first answer to this post (Swift pull to reload duplicates objects in table instead of updating) suggests, I clear my old list before loading data from CloudKit. This means that, while the UIRefresh is active, my tableview goes through three states:
[populated with old data] -> [no data at all] -> [populated with new data]
If the user tries to tap a cell during the second phase, unsurprisingly the app crashes because the view controller I segue to depends on the info from the cloud.
I can think of 3 potential solutions to this problem, and I am hoping to get advice from more experienced iOS programmers on what the best approach would be (if any of these).
1) Save the old table list so that if the user taps a cell in phase 2 of the loading process, I can somehow have the app access that list.
2) Don't let the user tap cells while UIRefresh is active. (This seems unideal because I'd like to add an auto-refresh feature at some point.)
3) As the StackOverflow post linked to above mentioned in its second answer, I could pull down from the cloud only the most recently modified items...but this, I think, would be messy for my situation because any of the cells could have been modified, and all of them will most likely need to be refreshed in my case.
Any advice on best practices here would be much appreciated! Thanks!
My suggestion would be to only modify your data once the new data arrives. After replacing the data immediately call tableView.reloadData()
My solution #1 seems to work pretty well. Not sure if there are pitfalls to it that I haven't discovered yet, but it seems to work pretty well.

Game Center vs Socket Programming&Server for iPhone App?

I have requirement of developing an Quiz Game but real time. I have read a little about it and went through some tutorials and documentations.
I have a queries in my mind regarding making it real time and effective.
I want to ask that
Whether I should use Game Center or Socket Programming where server is made in PHP/Asp.net or Python.
As, the architecture which I am thinking to make is looks like as below...
Architect…..
Download All Categories.
Select Subject, or Category/topic, every category can have many subjects.
After selecting, you will press button, Play now, it will send query to server, that you want to play., server will choose any one who also want to play and searching for some opponent
After both opponents are selected, it will send data to both, means in response of previous request, a user along with data of questions will be send.
As every question has fixed time, fixed score, so locally it will be shown and calculated and score will be sent to server and server will also show score to both players. means another data will be send, but very small data, say one string or two.
As time will be over, another request will be sent and final result will be displayed.
Thanks
Proper guidance will be appreciated.

opening and closing streaming clients for specific durations

I'd like to infrequently open a Twitter streaming connection with TweetStream and listen for new statuses for about an hour.
How should I go about opening the connection, keeping it open for an hour, and then closing it gracefully?
Normally for background processes I would use Resque or Sidekiq, but from my understanding those are for completing tasks as quickly as possible, not chilling and keeping a connection open.
I thought about using a global variable like $twitter_client but that wouldn't horizontally scale.
I also thought about building a second application that runs on one box to handle this functionality, but that seems excessive if it can be integrated into the main app somehow.
To clarify, I have no trouble starting a process, capturing tweets, and using them appropriately. I'm just not sure what I should be starting. A new app? A daemon of some sort?
I've never encountered a problem like this, and am completely lost. Any direction would be much appreciated!
Although not a direct fix, this is what I would look at:
Time
You're working with time, so I'd look at what time-centric processes could be used to induce the connection for an hour
Specifically, I'd look at running a some sort of job on the server, which you could fire at specific times (programmatically if required), to open & close the connection. I only have experience with resque, but as you say, it's probably not up to the job. If I find any better solutions, I'll certainly update the answer
Storage
Once you've connected to TweetStream, you'll want to look at how you can capture the tweets for that time period. It seems a waste to create a data table just for the job, so I'd be inclined to use something like Redis to store the tweets that you need
This can then be used to output the tweets you need, allowing you to simulate storing / capturing them, but then delete them after the hour-window has passed
Delivery
I don't know what context you're using this feature in, so I'll just give you as generic process idea as possible
To display the tweets, I'd personally create some sort of record in the DB to show the time you're pinging TweetStream that day (if it changes; if it's constant, just set a constant in an initializer), and then just include some logic to try and get the tweets from Redis. If you're able to collect them, show them as you wish, else don't print anything
Hope that gives you a broader spectrum of ideas?

Can't reload MKMapView while doing other tasks

I got my MKMapView running fine on my iOS app. The purpose of the app is to scan a Wifi network for data all the time. Like many times every second. This is just a background task and the user don't need to do anything for that scanning process to work. But, for some reason the MKMapView can't load new tiles at the same time as I'm scanning in the background. I would be lame to show some code from the scanning because I don't even know which part that are interrupting the MapView. So, is this a common problem that have been seen before or is this something weird?
When I move around in the MapView without scanning in background from the Wifi Network the map loads fine and uses both cache and fetches data from the mapping servers.
When I move around in the MapView WHILE scanning in the background no maps are being shown. Just empty boxes that are "telling me that the map are loading".
I'm using this library https://github.com/FuzzyLuke/OBD2Kit to fetch data from an WiFi plug that is connected to a car while I'm trying to show the user's current location on a map.
Suggestions?
I dont know how you're scanning but I guess it is breaking the internet connection and the map view cannot connect to the server then
When you say "many times every second" - how exactly are you 'scanning' the wifi network for data, and what data is it? Because it sounds like you're creating many dozens, if not more, distinct connections per second, which is going to totally cripple your networking stack, and would explain why your maps can't load.
I would encourage you to share more information about what exactly it is you're doing on the network, because that's almost certainly where the problem is. I can guarantee there's a better way to achieve what you want than firing off tens or hundreds of network requests every second.

ruby on rails: solid method to change logged in client's browser location on time X even when they reload pages?

Im in the need of changing a client's browser location on a certain time X. It has to be solid even if a user reloads page it should redirect to location X
Below is my current (imperfect) implementation of this:
Im in the need to a way to make this solution solid OR an alternative solution if that would fit better. ITs to complex to share code snippets so I would like to reframe from that and discuss the concept instead and discuss how to code wise implement the missing gaps to keep this question overseen able.
Current solution:
Im currently using redis and faye to send data to a subscribed channel (at the client) at time X
This means that a jquery event (redirect of url ) will be triggered when the redis background scheduler pushes/sends this data at a certain time X ( which is always in future)
The problem is this is not solid, since on a page reload the pushed/send data is never received and rendered useless.
Even if it would be possible to save the last 10 sends/pushes in lets call it a "history" one could read it but say a user drops connection the excecution of this data would be useless since it will be to late and not in time.
*How could I overcome this problem? I prefer to keep the load server side and not use a client polling the server every 1 seconds to check if there is data received. that would not scale at all and would become a big problem if usage of the app grows.*
What ideas on this concept to make it solid or use another method to get a solid implementation of this idea? any comments ideas suggestions welcome thanks in advanche!

Resources