Search code examples
androidsocketsmultiplayeronline-game

Best approach to create online game?


I have developed a simple card game based on Scopy. Now I want to upgrade my application for 1 vs 1 online game. I'm not new to Java, I know sockets. I was wondering if there is a better way to start this work.

EDIT: it is a turn game, the players just exchange a string that represent a card.


Solution

  • If its a turn game, you don't necessary need socket, socket is meant for real time interaction. And its way easier to setup normal http request's than socket.

    If you choose to go for socket, you will need a node.js server and there are some plugins for handling android socket connection. Basically these plugins create a listener that receive messages from server and run a callback (that you define) based on the name of the message.

    Another way to go, thats not so pro, but its easier, is use GCM (android notification service) or parse.com. This way you skip the server setup, these apis basically run a node.js server and you can define some custom messages, then just handle the messages with a socket plugin like i said.

    EDIT

    Using GCM you can send messages directly from your device, using a internal (on device) java server. There are some examples in android official dev site. By the way, you can implement socket without node.js too