using android mobile as a server - android

I am developing a turn based two player android game. Is it possible to use one of the user's mobile as server rather than an external server to coordinate the game ?
I do not need much data storage. only 40 fields(text or numbers) to be stored and transmitted (for transmission , one value at a time) while the game is on. after game is over only user's current score is to be stored.
I guess to do any such thing I need to get ip of the mobile. Is it possible ?

You need more than just the IP since the IP is just an endpoint on the Internet and there is no guarantee that it is your device that answers if you talk to that IP. There is usually a local network behind that IP and you can't access devices in there with just the public IP.
The problematic part is establishing a direct connection which is (usually) not possible on the Internet unless you are in control over the Internet connectivity (router etc) and can setup port forwardings / firewall rules / whatever blocks direct connections. If you have no access - for example because you use 3G where the "router" is at your provider's datacenter - you will need at least a server to do things like hole punching.
Also a server used to find other's games (and IPs) would be a good idea.
You can however do all that if both devices are on the same WiFi and they can see each other directly.

I am from Skiller and I think we have exactly what you need.
#zapl is right, if you want your players to connect to your games using 3G or WIFI connection the best solution will be intermediate server that makes it possible to exchange data between the players. Setting up, hosting and scaling such a server may be very expensive and time consuming thing. We provide FREE SDK tools, using which you will be able to set up your turn based two player game in no time. We are handling all the server side maintenance so you could just implement the game logic and fire your game to the market asap.
Download the SDK from www.skiller-games.com and tell me what you think.
If you have any questions write us here or to developers#skiller-games.com

Related

Data transfer between two android devices which are on different networks

I am working on one project in which two android devices which are in different network need to transfer some data. Both device will have internet connection. It will be either Wifi or GSM provider.
Consider the following cases:
If one Android device has GSM network and
another device in some other place which has Wifi network
If one Android device has GSM network and another device has GSM network
How to transfer data in such cases?
I don't want to use server in between.
Please let me know how do I solve this issue. Any clue or any links which will help me. So far I didn't find any such things. Please help me...
Short Answer: You're going to have to use a server.
Long Answer: You could use bluetooth if the location is close enough or maybe Wifi Direct although I haven't personally used the latter. Although, ultimately a server will be the best option. If you don't know a lot about backend development I could recommend parse.com as a good service that makes creating backends very easy and has fairly high usage limits before you have to pay.
Unless a device has been configured with an external IP address, which is very unlikely (impossible?) on a cellular network, there won't be a way to directly contact it from an external device. Even on WiFi, most devices will never have an externally defined address.
If you had administrative control over a directly connected and externally addressed router, you could port-forward traffic to a single device, but that's likely not the solution you're after.
A much easier approach is to use one of the services that let you define a back-end w/o a lot of setup or costs. The most popular one is probably Parse.

How to detect if an Android mobile is near a computer

I'm developing a piece of software which consists on mobile clients and a machine acting like a server. This is for a highly trusted environment (not public), so I don't care much about security.
I want the clients to be allowed to perform a certain action only if they are, say, 2 meters from the server.
As the client is actually an HTML5 app, it would be better if the server perform the check, not the clients (maybe the clients can send its position to the server and then he performs the check), but if it cannot be done, it doesn't matter.
I have run out of ideas about how this can be done. I have thought about bluetooth and geolocation, but can that detect if the client is at least 5 meters nearby?
Is this even remotely possible?
You can use sound waves to do this. These links might help you get started:
How to estimate distance between two android devices? (bluetooth preferred)
http://www.ehow.com/how_6075947_measure-two-locations-using-sound.html
http://iqtainment.wordpress.com/acoustic-ruler/

Connecting two Android phones to transfer data between them over WIFI

Actually i am developing tracking app and want to send Location updates between two Android phones so that both can track one another over the Map. My application must get real time updates from other android device for better tracking.
I Have searched couple of techniques but don't know which one is best
Using Sockets: making one device as Server while other as Client
Possible Limitation:
What if IP address of Server is changed (because WIFI don't have a
static IP)
Cannot access if the IP address of server is private
Only client can connect to Server and Server cannot connect to Client
Using Intermediate Server: create an intermediate server and make a communication via that server.
Possible Limitation:
Slow because each Android device first send these updates to server
and then server push these updates to other android device
Please provide me your suggestion about which one is the best way to do this.
Since you didn't state the Device API level you want to support I'll provide you with an option for Android v4 (API level 14) devices. It's called Wi-Fi Direct and allows p2p connections between phones. It's essentially your socket approach, but allows easy neighbour discovery and allows transfers in both directions.
Well wifi is out.. Not for your stated purpose at least. Unless your map is quite small. Wifi is for say 100 meters (on a really good day)
Not knowing as much about android as I do of other mobiles, I'd say you're in for some pain.
I'd suspect connecting to your phone with a peer to peer might be a real slog.. some providers won't let it happen.
I have an approach more than an answer..
From an android phone, see if you can get your ip address.
From a desk, ping that ip address.
If it works, you're well on your way..
Id even say given the size of your info, you could use pinging as your main data carrier.
Pings can contain more than just random bytes. You could include an ID, and GPS in the contents you send in your ping. --- perhaps include a check sum ---
Do most of the work desk to phone, because development would be faster.. Then when your phone is capable of catching the pings.. Well then sending the ping should be easy as.

How to comunicate two androids devices

I'm developing an online pong game in which two players could play between them.
I though that for it, players will have to conect to a server and it will tell the players who is online to play. Also the server will save rankings and other stuff.
But for the play, at first I though to use the server for the match too (sending coordinates, etc), but I think that is not the best design because it is really slow.
So I'm thinking that android devices have to can comunicate between them, isn't it? Any idea? They have an ID...
If they can... the server could send the ID of the opponent and with that, the match will start comunicating the stuff between the mobile devices and not with the server.
Need some help pls!
You can set up a direct connection between the phones, definitely. Make it so the server coordinates the matchup, sends each player the other player's data (IP and such).
You'll have to use/develop a server/client system between the players. One of the players will act as a server and the other will connect directly to it. Make sure they can properly identify each other. You can make the central server decide which player will act as the match server. A simple UDP connection over the network will do the trick.
This scheme will save you on bandwidth for the central server and probably be faster for the players. However, it IS one more subsystem you have to code.
Make sure you properly weigh those factors and remember that a fast deployment is sometimes better than no deployment at all. (SOMETIMES)

How to send data from one android device to another?

Hi all I was wondering what options do we have to exchange data between two different android devices?
For example, User-A and User-B both installs my app. I would like User-A to send data (possibly just a simple message or user-A's location info) to User-B.
The functionality I would need is similar to the functionality that WhatsApp has. However unlike WhatsApp, I do not have a server and I was wondering if we could do data exchange between two different android devices without a server?
I was thinking we build it atop SMS or something.
Options for exchanging information between devices are the following:
Bluetooth - this would be between two devices in the near vicinity
TCP/UDP IP connection - this would be using TCP to open a socket directly to another server socket. That could be hosted on the phone or a shared server. There are pros and cons to both.
The pros of bluetooth would be no need for a central server. The big downside is this means you can only exchange data between two people standing within 20 meter range. The other downside is you have to pair the devices which not everyone finds easiest.
You can use TCP/IP connections to exchange data just like any client-server program you write on a traditional computer. This could be used no matter if your phone is using 3G/4G/WIFI/EDGE or future radio protocols. The problem is the IP address of the phone might not be globally reachable. The IP address of the phone might be a non-routable like a private IP. They might be behind a firewall or NAT address.
This is where a central server is probably needed to either exchange IP addresses for users, or serve as a common location for clients behind infrastructure that could block. This is where protocols like SWIFT come in handy for jumping firewalls. Even with things like P2P you still run into these types of issues with non-accessible devices, and tricks like this have to be used to crawl around them. Unfortunately, that means you probably need a central server even with the P2P model.
Without an external server to keep a list of all connected clients, you would need to implement communication in a P2P fashion. Depending on the needs of your app, you could have the user type in the IP address/email/phone number of the other user they want to exchange data with.
If you wish to use a server approach, you can sign up for Google's App Engine which has good Eclipse integration as well as a plugin to easily interface with an Android app. This would give you an infrastructure option without initially (or maybe never depending on how high you scale) having to put down any money.
Google gave a good IO talk showing an example of a web app that can easily communicate with an Android app. You could extend this to do what you are looking to do.

Categories

Resources