Connecting two devices using libgdx - android

I'm developping a video game on both pc and android using libgdx.
And i would like to connect them by Wifi or Bluetooth on a local network. The idea is to play in p2p, establishing this connection easily.
Please anyone can give help or source code for that, knowing that the connections can be : android/android but also PC/PC (since libgdx allows that)? I have absolutely no idea.
Thanks

Well because libgdx doesn't have good networking support you can write your own, but i've found that Kryonet is very good. It takes a lot of the hassle out of writing the network layer of your application and I've used it to connect mobile and desktop with no problems. Definably worth a quick view. It also has some good examples to get your up and running with a network game too.
I've also found this article by valve very usefull.

Networking is somewhat beyond the scope of Libgdx. There is some basic support for HTTP GET/POST/PUT, but it implies you already have a DNS name or IP address to connect to, which usually implies you have a relatively fixed "server" to connect to (not an arbitrary peer). Peer-to-peer networking is definitely beyond the scope of Libgdx.
On the upside, since Android and Desktop networking are already pretty close, you can use most any pure-Java networking infrastructure that supports peer-to-peer. See other Stack Overflow questions like: Peer-to-Peer communication options I think you'll discover that the really hard part of peer-to-peer networking is "discovery" (that is figuring the address of the peer you care about).

There is little to no documentation on it, but LibGDX does have a platform independant (Android, Desktop, iOS and GWT) socket class.
I'd link you to an example of it's usage, but as I stated; there's no written documentation/example.
However, I can give you this link as a good starting point.
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html

libgdx-net looks good. https://github.com/pepedeab/libGDX-Net
Ive not yet tested it myself though.

Related

Viewing Media from a Raspberry Pi on a smartphone

I'm relaive new to this topic so my questions are more theoretical.
I try to establish a wireless connection between a Raspberry Pi and a Smartphone to view different kinds of media (Text, Picture and Video). I have some questions regarding this about if and how this works in theory.
Is it possible for the Raspberry Pi o work on a "Standby Mode" until a client device comes near/activates it?
What are the things i need to know about the Raspberry being a server and able to communicate to other devices over WiFi? What kind of software should I use for that purpose?
Is it possible to view the File structure of the Raspberry Pi without an individual app on the smartphone (i.e. web browser)?
In case of testing the concept, which tool(s) should I use to have a relative simple way of testing conections? Is there already an (open source) project existing in hat area?
Would appreciate all / any advice.
I guess it depends on what kind of technologies you are most comfortable with. You just need to have in mind that you are working with a RPI, so it's probably better not to push it and run your full stack on it. You can always use something like Node.js and run a tiny server/API on the board, to which the devices get connected. However, there are some interesting solutions out there that work as some kind of "middleware" and allow you to offload a lot of computational and even development effort to a 3rd party.
If you are not really concerned about the "owning" the setup and don't want to waste time spinning up an entire stack you can try something like Muzzley. It will also require you to run software on the RPI (despite not being a full stack on its own), but most of the communication and interface configuration is available off-the-shelf. It provides an appropriate protocol and a library of components you can just use from the get go. On the other hand, it is flexible enough to allow you to roll out your own components.
I don't believe it will help you directly with your specific issues (standby mode, nearby device detection or file system access) - which should be solved by your own application and software stack - but it will save you a lot of time on more generic stuff by allowing you focus on that issues only.
Full disclosure: I'm part of the team working on Muzzley.

Android: UPnP device scanner sample

I'm wondering if anyone has an example of a UPnP device scanner which I can import to eclipse. I would like this since I can understand how it works a lot easier when I see what it does in the emulator.
Thanks
I assume that by "device scanner" you mean "media controller" aka DMC. If you insist in having the DMC in Android emulator, then you can probably use Cling UPnPBrowser, which is basically a working example of how to use Cling in Android.
Observing and debugging in emulator is unnecessarily tedious too - if you want to learn UPnP, not as much Android. From the point of UPnP, the platform doesn't make any difference. A corresponding desktop app is completely equal (regarding UPnP internals) and way more comfortable to play with.
Also, instead of diving into the code, i would suggest starting with some basic documentation, so that you know what's the stuff that DMC is sending to the network and the other buzz on the wire even if DMC doesn't ask for anything.

Android Multiplayer Game with Socket Programming

I have been searching if it is possible to develop a multiplayer game with socket programming on android platform over WiFi but I couldn't come across with a certain answer.
As I found out, there are ServerSocket and Socket classes in android sdk.
Can I use those to establish communication between 2 devices, over WiFi?
Also if I can make 2 devices connected somehow, how should I combine this with my game architecture?
Any advice will greatly appreciated. This is my first try on Android and Socket Programming. I heard about Skiller, WiFi Direct and some other stuffs but It has to be done with Sockets.
I am actually from Skiller and I will try to address at least some of your points:
Why do you need sockets for your game? It will help a lot if you will explain what exactly you are trying to achieve. Maybe there are other, less complicated, ways you can achieve the same thing. And integrating the communication solution with your game logic relies directly on that.
Directly connecting two devices, whether they are connected using wifi or 3G is a very complicated task. In order to do so you need to know the IPs of the devices and it varies from difficult (wifi - depends on the wifi you are connecting to) to almost impossible (3g - you can not see the ip of the device behind operators proxy) unless you implement couple different techniques or use intermediate servers to do that job. These solutions of course will cost you because of a hardware resources and the most important time resource. From my experience in that field I strongly recommend to use existing solutions if it matches your needs (and I am really trying to be objective ;))
Hope it helps to further investigate what you need for your game. If you want to check out Skiller SDK you are more than welcome to do that in our wiki: http://wiki.skiller-games.com/ or send an email to developers#skiller-games.com
Michael

Android, VPN, Asterisk communication

I'm trying to write a voip app for Android, using the Android SIP API (Yes, I know this only works with some Androids with version 2.3). I want calls to be routed through an Asterisk server. The calls also need to be encrypted. A problem exists where Asterisk and the Androids need to be on the same subnet (otherwise no audio is exchanged). There is a nice blog post I found at http://blog.harritronics.com/2011/06/android-gingerbread-and-asterisk-pbx.html describing the situation for those that are curious.
I'm looking to setup a VPN solution as discussed in the article as I figure this could solve the NAT issue, along with encryption. My first thought was to use OpenVPN since there is a pretty active community and the software looks pretty nice. However, after further inspection, it seems that I can only have 2 clients active on the VPN server at any given time (for the free version). Each additional client connection is $5. In short, I'm wondering if a scalable free solution exists. I would like to be able to connect somewhere around 100 android phones to this VPN to communicate with Asterisk simultaneously.
Also, I have done no VPN work previously. I'm wondering can I simply use the VPN configuration within the Android Settings? Or does there need to be an additional application? I saw that OpenVPN had a client solution for Android that only worked if the phone was rooted - this is not an option, as they are not my phones. Any advice would be greatly appreciated.
Thank you!
Not sure what you've been looking at, but OpenVPN certainly does not have any restrictions on the number of clients. Anyway, as you have found out, OpenVPN is not supported by the default Android distribution, though it is integrated in CyanogenMod. Android also has a built-in VPN client however, so you just need to find a server that works with that. As of 4.0 (ICS) it is also possible to write your own VPN implementation without rooting the phone.
BTW, the audio problem only arises if the phones are NAT-ed (e.g., connected via WiFi to your internal router, etc.). If the have global addresses, there should be no problem. If you connect over 3G that would depend on whether your carrier gives phones actual global addresses.
Another alternative is not to the Android SIP stack. There are other solutions available, and they might not have this restriction. Check sipdroid, it open source:
http://sipdroid.org/
Yet another alternative is to not try to write your own app, just use sipdroid :)
Besides the nat=yes option of Asterix I only think in one more solution. That nat option worked for me behind a router but I know that it isn't a very "inteligent" NAT traversing from Asterisk, it needs "colaboration" from the client too. The other solution could be... when I was working with that, I was using CSipSimple, it's an open source voip client for Android, may be you can look at the sources and find why that traverses works behind a router doing NAT.
If you're looking just for an Android VPN client, there are some of them, at least one with a 100% free option.
Hope that helps!

Android game networking

I need help finding the best method for networking in a multiplayer game. I want to connect to a phone and maintain the connection until the game is over, hosting the game on one of the phones. There are other threads, but none of them really explain how to connect or use the networking, only saying to use such-and-such library. Examples or links to good tutorials would be extremely helpful.
You have to options: TCP/IP sockets or Bluetooth.
For TCP/IP socket there is a good discussion on "Thinking in Enterprise Java" by Bruce Eckel, you can access the digital edition for free (see chapter 2).
Fro bluetooth there is a tutorial on the android developer website. Just be advised that peering between phones is supported only starting from android 2.0.

Categories

Resources