How to pair random clients with each other? - android

I'm making a client/server game app for android. Currently I managed to get the app working using two locally known IPs. My issue now is how do I go about making my app pair client/servers randomly.
I was thinking that initially every person starts as a client and they connect to a master server. The master server then pairs them together and specifies who will be the server and who will be the client between the two. If this is the best way to do it, how do I go about making the master server program? What kind of server do I set it up on? I'm in the dark about how to go with this.

actually i did not answer right away thinking i would waste the night in needless fear but let us - if you don't mind - bump the issue up the hill - given just now i am going clickety-click looking for places to put up my first app - i found 2-3
let us examine the chance to do conceptual work on what is called stochastic List
given a large dataset = available apps
and another large dataset = people looking for apps
how would we code a fair presentation algorithm as some numbers like 100,000 are not out of scope but we get the same 10-20 apps on many keyclicks & not get much done - thus:
class Customer{}
class Application{}
Map <BigInteger,Customer>
Map <BigInteger,Application>
then we look into SecureRandom to pull from the application base ....
lot of work to be done but major point is to use SecureRandom rather than Math.random for several reasons ..

Related

To create a Tendermint Private LAN BlockChain and access it

I am working on a review submission project on Tendermint in Windows.
I want to submit a tamper-proof review about a organisation and hence want to create a private block-chain network with no validators and say 5 users, who submit their review via android app through abci-cli to the private blockchain.
Can anyone guide me how to proceed with this. I am new to this whole topic and very confused about where to start.
I got this How to create a Tendermint local network with same ip
but want to run say 5 user accounts from different mobiles and Tendermint on 1 laptop(to create Blockchain). What I want to build is possible?
Any help is appreciated.
First of all, if you want to create a tamper-proof review system, you'll need as many validators as you can have, not just one. You need them because it's straightforward to hack one validator and exploit your system. But if you have many validators, it's not so easy (given they are independent - different data centers, racks, ..). The whole power of blockchains emerges from having a large number of separate machines which can't easily be hacked.
Second, you can have as many users as you want (of course, there is an upper limit on how many txs per second Tendermint can process).
Third, it's better if you use native Android API to send transactions. Tendermint has 3 HTTP endpoints for transactions (https://tendermint.github.io/slate/#broadcasttxsync).

How to detect nearby android devices using the same app

So basically I have made a few small apps in the past, but this is my first 'proper' app.
One of the main features of the app, and the bit that I am struggling with is that I need to be able to populate a ListView with all of the other users logged into the app, however I only want to display users that are within a set distance, for example 10 meters.
I tried using Bluetooth to achieve this, however that didn't work. I would now like to use location services to do this.
My idea is to have to app send the location of the device to an external server every few minutes and then all other devices can run a function that compare their location to others found on this server.
Does anybody know how I could go about achieving this, or know of any tutorials that cover a simpler topic. Thank you
Disclaimer: I'm not an android developer, but this seems like a design issue not a implementation issue so hopefully my comments below might be of some use...
I don't think there's an API that you can just set to "true" to get this functionality, so I think you're going to have to custom craft all the moving parts (and there are a couple). I would think the general process would be something like:
On the client:
User on client logs in to server with some sort of identity (i.e. "user#gmail.com")
Every X minutes the client app gets the current location (i.e. "100N 90E") and sends it up to a server
Every X minutes the client polls the server to see who is within 10 miles (i.e."joe#gmail.com", "mary#gmail.com")
On the server:
Needs some sort of authentication endpoints for getting a user's identity
Needs an endpoint for users to register their location ("user#gmail.com is at 100N 90E")
Needs a service to find out how far each user is from each other
Needs an endpoint to return the users within X miles (list generated from #3)
Each one of these steps shouldn't be difficult on their own and you can actually get pretty nuts with the distribution algorithm on server step #3 if you wanted to.
Some questions you can ask yourself are:
"How do I set up a server to listen for HTTP requests?" - Take a look into Node.JS for a simple solution
"How do I get a user's location in android?" - Easy google search finds plenty of documentation
"How do I write a service to continuously perform actions?" - Node.JS would again help with this
"Where will I store user's locations and their distances from each other?" - You can look into a NoSQL option like CouchBase or MongoDb. Or you could use MySQL for a more structured database.
Hope this helps...

Best method to store and read data from a cloud source in Android?

The situation: I have many real life locations with specific information associated with them, and updated frequently. I am unsure of how to store this information for use in an android application.
My original thought was storing the data on some server/cloud source/database, reading from the server from each Activity in the app to make sure the info is up to date, and update the server with any changes that may or may not have been made.
For example: there are 200 people inside the library, one person leaves.
So we would read the number of people from the server, display this on the app, person leaves, subtract one, send the new number back to the server.
Would this be an incorrect approach? I'm fairly new to Android in general, and I really have no experience on how to approach this type of situation, what services to use, etc.
I would look into using Parse, its a pretty sweet way to power the backend, and their website is very detailed in explaining how to use it.

cross-platform real time update for mobile phones

i'm looking for a way to sync items stored in a database among users
so anyone of those users changes anything from his phone , the change will be reflected in the database and SYNC with all users related to him in real time
what's the best way to achieve the real time sync ? push notification ? is Urban airship what i'm looking for ?
Syncing data well is often specific to your application and your data. It's beyond the scope of an SO question but here's some thoughts if you implement your own ...
Some of the interesting design points are:
Reliably getting a delta
Dealing with conflicts
How real time is real time?
For reliably getting a delta, be careful about relying on date time for distributed machines. This post discussed some of those challenges and some alternatives.
Can I Rely on the iOS Device Clock Being Correct?
Merging new entities is easy but if multiple folks are editing the same entity, you need to decide how to merge. For conflicts, you can in order of preference (1) auto merge - come up with an algorithm that automatically merges the content without user intervention and ideally with no data loss (2) rely on the user to merge with an interface and (3) a form of auto-merge: last write wins. There's also variations where you interleave the revisions - it's a form of last write wins but the revisions are maintained . You can also auto merge at a field level of an entity if that's appropriate. My post to the question above covers interleaving but it depends on what your data is.
How real is real time? When syncing occasionally connected devices, the devices will getting farther and farther out of date and it takes time to catch up. Consider batching sets of changes in the communication pattern to optimize but it will still not be real time. Embrace that in the design - does the user see data animate into there current views as data is synchronized?
Architecturally, you'll likely want to expose your data in the cloud through REST services or SOAP web services since it's cross platform. For multiple devices platforms, you'll likely end up porting the sync algorithm. The best you could hope for is using something like Sqlite so you can share your devices database schema code and sql statements.
I would start with Dan Grover's presentation, "Cross-Platform Data Synchronization": http://iphone2009.crowdvine.com/talk/presentation_file/5104/Grover_Syncing.pdf

Game server for an android/iOS turn-based board-game

i'm currently programming an iPhone game and I would like to create an online multiplayer mode. In the future, this app will be port to Android devices, so I was wondering how to create the game-server ?
First at all, which language should I choose ? How to make a server able to communicate both with programs written in objective-c and Java ?
Then, how to effectively do it ? Is it good if I open a socket by client (there'll be 2) ? What kind of information should I send to the server ? to the clients ?
Thanks for your time.
EDIT How massively multiplayer'ed will you game be?
Hi Cyril,
as you noticed, there are two main things two consider:
information sent to the server
information sent to the client
There's only one type of information to sent to the server: the user inputs. If you don't do that, you'll encounter headaches over headaches when rogue client will try to send fake data to your server (like saying "My tank now has 100 000 000 armor").
Then what you sent to the client is up to you but it's totally possible to only sent to the client the other player(s)'s input. This is the way to have the absolute minimum and tinies bandwith usage possible. That is how games like Blizzard's Warcraft 3 are doing it. As a bonus, this makes for tiny replay files (because all you need to do to be able to replay a game is the time (and the input) at which each player's input happened).
The one downsides with sending only the other player's input to the client is that it means all the game's logic is present on every client. For some games, this may be an issue because people may cheat by reverse engineering your game and finding flaws. This issue can be mitigated with careful, controlled, randomization (where in addition to the input+time you send input+time+randomness where randomness cannot be guessed by the client in advance.
Another way to do it is to do some logic computation on the server side. Then, obviously, you need to send the result of the server computation to the client. Done correctly, this has the benefit of both preventing cheats and maky piracy impossible (for example nobody managed to play World of Warcraft in the real economy --that is, on the real Blizzard servers-- using a fake licence key).
Regarding the phone-turn-based game server: just look at one top-selling turn-based game are doing it. Take Uniwar for example: works on iPhone and Android. Game server is written in Java "of course".
The one thing to realize is that a game like the one you plan to write is entirely deterministic: if you can't easily code a replayer or if you can't easily reproduce any kind of scenario leading to a logic bug, you're doing it wrong.
Note that being determistic doesn't mean you can't add what looks like randomness to your players: it's simply that the randomness shall also be deterministic (for example by simply using a different seed for each game + the time at which player inputs are made as a fake random source).
This is a bit lateral solution to the question asked. One of your options is to use Gamooga (http://www.gamooga.com/) so you donot need to worry about the server side, the sockets, the transport logic etc. You can just concentrate on your game logic and just develop that than the required systems stuff.
Gamooga provides you with a realtime communication platform to be used in your games. You can upload your server side message processing scripts to Gamooga's cluster and use its iOS API with in your app to send and receive messages from/to the server side. The server side is auto scaled and managed for you by Gamooga. You can download the SDK and start off with the demos with in the SDK.
Disclosure: I am founder of Gamooga, replying only since its relevant to the question.

Categories

Resources