Reputation: 1258
I want to make a game using java ( really, i want to do it in xna, but first i want to do a prototype still learning xna ), and i got the idea to connect it with php for multiplayer capabilities.
what i want to do is make the server side on php (and use a hosting, or my university server) there is no need to have something really "fast" ( i have all the game planned, turn based, and part of coding done )
my idea was,
php is running the game flow, the server will be connected to both players, and both players will be connected too. when players1 make a movement, sends it to the servers, and sends a signal to player2, then, player2 ask the server what have player1 done ( all this is for security issues )
my question is, i was thinking in make java connect php as if it was a web page as any other, but i think that wait for the http response could be really slow, somebody have some tip, another way i can do this?
Upvotes: 2
Views: 400
Reputation: 477
i would suggest something using the COMET model, this way you wont have latency issues as the connection is already made and is waiting for info to come in.
this will be essentialy a long polling solution.
Upvotes: 0
Reputation: 20885
Maybe PHP is not the right choice here. I'm not a fanatic of this or that language, I usually say that everything can be done with whatever language you are proficient in. However there's a problem with PHP, and it's that the language was not designed for general purpose, but specifically to preprocess a document to be served in a HTTP response.
This makes things like multithreading, long running scripts and so on, practically impossible with common setups and libraries. We can't tell more because you didn't share enough information about what you actually want to connect, but if you can use Java then is definitely better to go with it for both the client and the server (and incidentally you also may save some type by reusing the same libraries on both parties).
Upvotes: 2