Multipeer Framework with multiple sessions at once? - ios

I’m attempting to build a multi peer network app and I’ve got everything working for a single conversation between two users however the intention was to build a master- -> detail app like whatsapp where you have a list of conversations and tapping one takes you to the conversation. The problem I’m having is all the housekeeping in maintain multiple sessions.
My structure is that I have a ‘conversation manager’ which has an array of ‘conversations’ which are wrappers for an MCSession that have an array of messages. When a conversation is started (either by inviting a recipient or by accepting an invitation) the conversation object(session) is added to the array, which is the data source for the master table view. When a conversation is selected from the list, in prepare for segue I pass the conversation object to the detail view controller and it’s array of messages become the data source for the detail screen.
I’m having numerous issues trying to get this working, such as messages not being delivered in conversations currently not on screen, keeping all the sessions active, not allowing multiple separate conversations between the same two people etc.
My specific question is that, most of the examples and tutorials, including Apples sample app focus around one conversation, one active session at a time. Am I wasting my time trying to get this working. Ie. Was the framework only designed to accommodate a single active session at a time?

I ran into this curious about the same thing!
I realize this is nearly 3 years old but here's a thought:
If you're using MPCF then you're accepting that these chats are within wifi/bluetooth range. Well, you could accept the limitation of one session at a time and the limitation of up to 7 active chats at any time. You and seven others? 1:1 Then you can just pair those chats up. Each peer could have 7 threads. We can assume that only 8 people have your app open and are within range? I realize this doesn't -completely- solve your problem but it hopefully it gives some direction since I'm not sure another option is possible.
And no answer/help for three years kinda stinks so I'm hoping to pitch in!
If you did find a better answer I'd love to know what you found!

Related

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.

Linking online databases to a project for iOS

I'm working on an iOS app for having a list of top 10 of everything.
So the problem I'm facing is how do I update the list every week ?
I thought of linking it to external links but then I was unable to format the webpage according to the interface of my app.
Lastly I want the app not only to display the top 10 list but also to be able to interact. For example if the user enters into top 10 songs then he should be able to play the tracks as well ! So for this I guess I'll be needing a database which I could update weekly. I don't know how to go about this. Please help !
You need a remote server, running with an application that handles the list generation/updates, and you will probably need also to manage a remote database, if you expect that the number of item will be reasonably large.
Your ios application will have to interact with your remote server using an API that you will have to define as well.
I'm sorry to be that generic, but the hard truth is that there is no quick or easy way to do it: you will need to learn and possibly develop every part of your system and then integrate them.
You have nearly an infinite number of options in terms of platforms/languages/databases to choose from, for the backend part.
Over the last few years, there have been services that should make handling the remote backend easier (Stackmob, cloudbase...) but it really depends on much control you want to have on the "lists" you want to manage.

How is data typically reloaded/displayed on a device when only a tiny amount of data changes after updating the database? (Conceptually)

Here's and example of what I am talking about:
Take Twitter for iOS. Whenever you tweet, the tweet is sent to the database, and then it is also displayed on your device as part of the list of tweets.
How is the list of tweets that you see on your device updated after just sending one tweet? Here are some possible ways that I thought of how it could be done, but what Im asking for is which one is the best method of doing so:
The whole list of recent Tweets is re-downloaded from the remote Twitter server after sending a tweet (I highly doubt this, as this would take a relatively long time, when it really is just appending one Tweet to the array of Tweets displayed)
The local array that holds the Tweet objects is updated separately from the database (For example, it updates the database, and then updates its array with the same data you sent to the database, and never downloads the Tweet you just sent since you don't need to, because you already have it locally, since you composed it)
Is Core Data capable of updating the remote data server AND the array all in one (or relatively few) step(s)? (Sorry, if this is the obvious answer and if it sounds like I didn't look into it, but I did read about Core Data and started a tutorial. Its just that there is so much content that it would take me a whole day or two just to figure out if its appropriate for my application)
Is there an alternative way of managing this?
Also, if its one of the latter two ideas above, are you able to update the table view cells by just updating the local array and reloading the cells from that array without loading your one tweet from the database? I'm just curious about what would be the most efficient way of doing this.
So again, my main question reworded is: how do you keep data that you sent to a remote database and the local data (stored in a mutable array) in sync whenever you do a tiny single update (such as sending a Tweet) without having to reload all of the data from the database (when there is other content [i.e. other Tweets]) already loaded.
(I am aware that no one except Twitter developers know exactly how Twitter actually done, but I'm just using this Twitter functionality as an example. This same concept could be applied to any similar app.)
(Also, this is a conceptual question about dataflow, so I don't need to see any code, but suggestions to use different technologies like Core Data, or just updating an array will be appreciated.)
(I've been looking into this, and all the different ways of doing it, and it is becoming very time consuming, so I figured to ask you guys who have experience. Additionally, this could help someone else who has similar questions.)
(Sorry if it looks like I'm asking a bunch of questions, but I'm basically asking the same question in different ways, and offering possible solutions.)
Any insight is appreciated!
Immutable messages like tweets are actually quite easy to handle -- server side, and in your app.
When you send a tweet from your client to the server, you also update your "main context" (see "Managed Object Context") which in turn sends notifications to your controller (see NSFetchedResultsController which in turns updates your table view according your local model residing in the Managed Object Context.
Updating from the server is just merging the local tweets with the new ones added in the meantime.
Since there is no mutable tweet, synchronization is really no big deal. As mentioned in the comment, if there were mutable tweets (or any kind of messages) the synchronization will become much more complex.
Core Data will NOT automatically update a remote server. But there are solutions to "view" a remote database through Core Data - see NSIncrementalStore and a related third party libraries (AFIncrementalStore).
This is ridiculously trivial. You update your local database and send off the remote update at the same time.
You use the remote response to mark your local record as synched or try updating again later.

Tracking User Journeys with Flurry Anayltics

I have an iOS App where a sequence of three events spread across three Pages constitute a single Journey.
I can log each page view and single events via flurry.
But can I log the entire sequence as a single event ?
PS: I considered using timed events but didn't seem like the best fit.
Are you trying to track the conversion of this particular journey. If yes, then this is definitely possible by creating a funnel of these three specific events. For more information on funnels please refer: http://support.flurry.com/index.php?title=Analytics/Overview/Lexicon/FunnelAnalysis
However, if you are trying to log this particular journey as one single event, then that also can be done. You need to flag all the three events/pages and create an event, which gets triggered/logged when all three flags are true.
If you need further details please reach out to us in support#flurry.com.
Thanks

Multiple database records in a table vs database queries? What is the best for performance?

App running on: ruby 2.0, rails 4 and postgresql
1.The multiple tables story - How it works now:
A project has many users, as members.
Also project has many posts, when a post is created a notification is created for each project user.
Let's say if Project A has 100 users, we'll have 100 notifications in database, this will load the database with a lot of duplicates.
But a user can delete its own notification, can view it, we can update his notification with user specific data. And we'll use a rake task to remove the notifications that are older then a specific time interval.
2. The multiple db queries - What we want to do:
There is an idea of creating only one notification for an activity and use many to many relation with a table called notifications_users where we'll keep information about a notification if it was read by a current user, if this user removed this notification from his notifications tab, etc..
The downside of this I think it will be multiple db queries as when we'll need to find something about a notification and user we'll have to look up for the notification_users table to get the information needed.
Also, by building the relation this way it will be harder to clean up the database from old notifications as we will not know if this notification was read or not by some user.
Thank you.
The option (1.) seems pretty reasonable and if you can keep the notification model thin — like user_id, activity_id, timestamps, and maybe a couple more flags, then wouldn’t expect unreasonable performance penalties, since it looks like a pretty usual relational model and I’d expect the database to easily handle it.
If you keep you notification expiration tight, this means that the notification should not grow, or if it does, for example when user just abandoned the account, I would look for specific solutions for the issues, as the appear.
At Assembla.com we do notification with email and this is working pretty well for us, I’d say. So, maybe at some point, you may want to consider this option too.
It seems to me that the (2.) just doesn’t fulfil the business needs, and if you’re not considering them than it’s probably not worth considering this option either.
Before analyzing scenarios given in your question I would like to request you to clear one point which is a bit confusing in your question. The statements given below are confusing.
1) Also project has many posts, when a post is created a notification is created for each project user.
2) Let's say if Project A has 100 users, we'll have 100 notifications in database, this will load the database with a lot of duplicates.
Statement no. 1 describes that when a post is created; a notification is sent for each user. So suppose there are 100 users and 100 posts then the table which has notifications data will have 10000 rows (100*100).
Statement no. 2 describes that if there are 100 users then there would be 100 notifications in the database that means the notification table will have 100 rows.
Of the points given above which one should I consider.

Resources