Internet connection for multiplayer games

Short story: Me and a friend are making a multiplayer game and we thought it would be great to play. Android, Java and HTML5 support is the most important, but we don't want to cut out the others unless needed.

The problem arises when we want to implement the network part of it. We implemented our own server and thought we would use long HTTP requests to communicate. We estimate that we need to somehow start one thread for communication using messages and two multithreaded secure queues. One queue for incoming messages that the update () part can consume, and one queue for outgoing messages to the server.

Is there a way to implement this without losing platform support? Or any other idea how we can implement this?

+3


source to share


1 answer


PlayN does not currently support cross-platform persistent socket connections to the server. You will need to implement your own cross platform abstraction. You can use WebSockets for the HTML5 backend and you can search for the Android WebSockets library and any other platforms you intend to support.



You can also use the Nexus library which is designed to work with PlayN and provide client / server communication. However, it significantly raises the level of abstraction beyond the simplest messages between client and server, so it would be easier to just implement your own simple messages based on WebSockets than to learn how Nexus works.

+4


source







All Articles