How does one? - N phone connection / chat / data.

Stepdragon

Member
Licensed User
Longtime User
I'm working on an app where I want to be able to have any number of clients (apps) to be able to automatically detect, connect, and communicate with each other with as little user interaction as possible.

I'm working on a game life tracker, and I want to have each player keep track of his or her own life, and have the logs appear on every device. I want to be able to click a single button, and create a local game room (whether it be Wifi, or BT) and anyone in range could detect and connect to it...

The thing here is that I don't know where to start. I want to use the BT serial tutorial, but can't only two devices connect with bluetooth? should I go with a local Wifi hotspot? or Ad-hoc network? but is that something which can be done easily, and wouldn't that possibly fudge up some of the user's settings, or worse, disconnect background apps such as music streaming?

Any Ideas how best to implement this?

I am also considering using a real chat protocol, but first off that would use data, and either require a server myself, or that I generate chat logins for the users, or that I hijack their chat accounts. none of which I want to do.

I hope this makes sense, and that someone can point me in the right direction here. I just need to figure out an easy to configure quick connect and disconnect communication protocol for n devices.
 

rfresh

Well-Known Member
Licensed User
Longtime User
I'd use the http protocol to communicate with a server running a MySQL database. Your app can connect every 30 secs to check for other users and send text back and forth, etc. With the right DB schema, you can do pretty much what ever you need to do. This would work fine, be robust and be highly scalable.

I don't think BT would be workable for this at all. Unless I'm mis-understanding your design, BT would be extremely limiting.

Your idea is a good one but will take a lot of work to make it happen...so good luck with your design research. If you end up using a MySQL database, it's schema design will be critical to your project success and literally be the beating heart of your app. Keep us posted on your progress.
 
Last edited:
Upvote 0

Stepdragon

Member
Licensed User
Longtime User
The problem here is, I want to make this a standalone app. I'm trying not to have any server interaction for multiple reasons (not the least of which is that I don't have a server, or money for one).

In addition, I want this app to function on devices regardless of connectivity. For example, I'll eventually make a tablet version, and I can gurentee that 80% of tablet users who play my game won't have a 3/4g connection and won't be near a wifi hotspot...

I agree about BT being too limiting... how difficult would it be to create a wifi hotspot on a host, and have other's connect to it automatically? is that something B4a can do (or rather, is there a library yet implemented for that?)

I'm already making a lot of headway in the fuctionality of my app. If I don't implement the auto syncing, it'll just be a much cleaner interfaced version of a few apps already on the market (ok and its easy to use)... but with this functioning, I know it'll be an instant hit.

I'm just not sure where to begin.
 
Upvote 0

timwil

Active Member
Licensed User
Longtime User
I think you would need to have a server of some sort - when your app starts it will have to connect to something - some constant - from there it can see who else is available
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
I think you would need to have a server of some sort - when your app starts it will have to connect to something - some constant - from there it can see who else is available

Tim is 100% right. You will need a server. I don't see any way around it. You can get a Linux server/website for 4.95/mo that can do everything you would need for this project including having MySQL for your database - PM me if you want to know from which company.

Your requirements are out of sync as I've read them: You want the app to function as a stand alone yet be able to communicate with other players? You can't have it both ways.

I don't think B4A can create the wifi hot spot you have in mind. This requires an ISP and think about it: where will a player be when they connect? You don't know. And who will provide the connection? Again, you don't know, but it won't be you.

The devices will have wifi so it will be up to the player to be near one when they play if they want to communicate. You cannot create the wifi yourself if that's what you mean, I could be mis-reading your intent on this one, but you cannot create your own wifi hot spot. And even if you could, why would you? You'd be so limited in area to connect to it. Why bother? You need to really think about connecting to a server for this to work.
 
Upvote 0

Stepdragon

Member
Licensed User
Longtime User
Maybe I havent explained very well.

My target audience for this app is 12-18 year olds who happen to have a smart device (not so uncommon in this day and age). It is going to be a Magic the Gathering card game life / stats tracker app.

when I say 'Standalone' I'm referring to not needing to connect to the internet to function. That doesn't mean I don't want to use the networking hardware (ie. ad-hoc).

Because of my target audience and usage scenareo, the most likley locations of use are libraries, after school in cafeterias, or other table top meeting places. I don't want to use the data connection due to the age of my audience, and I don't want my app dependant on a data connection or wifi network (a lot of people just don't have it, or won't be in a hotspot, I know I wasn't when I was playing)

The Idea here is that one person could create a hotspot (I know its possible, but not how), not even to share data (because a lot of carriers like to limit that sort of thing), but only to create a local network just for the sake of the app. this way one could 'create a game' by clicking a button, and other's could 'connect to a game' thus changing the app from hosting, to searching.

I don't see a need for a server because I want this to be device hosted. I could implement a local chat protocol between devices, but that comes after creating a connection. and that's what I'm looking for.

In regards to 'why would you create your own wifi hotspot? You would be in a limited area...' - This is an app for tracking a card game's progress. If you're using it, you can be sure that everyone else in the game is within 5 feet of you, so distance is not an issue. that's also another reason why i don't want to depend on a server connection. what if you were playing in a basement with no cell signal, when the only person you're communicating with is right next to you?

I can worry about the logistics later, but for now, I'm just trying to figure out some way of communicating between multiple devices locally. I'm sure there's a way, but it just hasn't been discovered just yet.

Does that help clarify why I'm looking for such a solution? I'm sorry if I wan't being clear.

Also, thanks for the input so far.
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Yes, that's more clear. So, in that case, BT could be an option. I say could be because I don't know what kind of communications between the devices you intend to design in. So I would say BT could be an option depending on what data needs to flow between the devices and what needs to be saved, etc.

If one of the players turned his/her smartphone into a wifi hot spot (which is what I think makes sense to do vs YOUR app trying to do that which I still don't think can be done) then in the wifi hot spot scenario, you're still talking about using something like http to talk to a server. A wifi is connecting to the internet and you would need a server to be the 'data traffic cop' to handle the data flow between devices. That's the best design.

However, I think you could do away with the server and talk to the devices thru their IP addresses (they must be dedicated IPs or this won't work) but that would put a heavy load on your app to manage all that traffic and data. While I think you could design it to work this way, it's not efficient at all to put that load on the devices. You'd really want a server to handle that, but you've said you don't want to go that route, so it sounds like BT is in your future!
 
Upvote 0
Top