• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Kobaltic

How do I push a php return to all clients

9 posts in this topic

I have client side written in javascript using http://phaser.io. I use jQuery AJAX to send information to my php server. I then process it in PHP and MySQL as needed. Then I use json_encode to encode the php returns and then echo out the result back to AJAX. I take it back in then parse it back out for javascript.

 

My problem is that it works great for one player. I am not sure how to set up so that the PHP echo is sent to all the clients to update them. I was thinking about setting up a game id and recording all the clients IP addresses. Store them into the database. Then see if PHP has a function to send the information back to the IP address. Not sure if it will work though. Any other ideas?

0

Share this post


Link to post
Share on other sites
It won't be possible to do this the way you describe. Assuming a basic LAMP setup, each client connection essentially creates a new, independent PHP process for the duration of the connection - it is torn down at the end. Web browsers do not listen for incoming connections from servers, so it isn't possible for the server to open a connection to a former client. In addition, most clients will be behind NAT and firewall devices, even if they were actively listening for requests.

One of the simplest things you can do is have each client periodically make an AJAX request to the server, checking for recently updated information. The frequency of this polling is something you'll have to tune to the desired responsiveness versus the bandwidth required.

A single long running custom server process, in conjunction with newer APIs such as WebSockets, or using plugins like Java or Flash, would be able to do something like what you describe. The feasibility of these potential solutions depends on your hosting options and what kind of browser support you want to achieve, as well as the time it might take you to master any unfamiliar technologies.

Can you describe your game in a bit more detail? A fast paced action game has a much different set of networking requirements than a turn based strategy game, for example.
1

Share this post


Link to post
Share on other sites

Thanks for some more information. The game is a turned based trading card game so time and bandwidth won't be much of an issue. However I do want to do faster games down the road and would like the correct way to handle this.

 

I have my own VPS and I can put anything needed on it. I don't have much of a problem learning new technologies.

 

Could I use something like node.js or websockets to handle connections and still use PHP as the server?

 

edit: corrected typos

Edited by Kobaltic
0

Share this post


Link to post
Share on other sites
I haven't actually developed games with these technologies, so I'll refrain from recommending any specific one.

That said, I'd probably go with simple AJAX polling for such a game. For a fast paced action game, I'd strongly consider writing a dedicated server process of some kind. I personally wouldn't write such a server in PHP, but I'm sure it could be done.
1

Share this post


Link to post
Share on other sites

Thanks again for the information. I think I am going to look into some different server options and see what I come up with.

0

Share this post


Link to post
Share on other sites
How this is typically solved, on top of PHP, is that players poll every once in a while (using client-side JavaScript or whatever.)
If you want something better than that, you need to use websockets, either using socket.io on node.js, or usign something custom. We ended up building a custom system on top of Erlang, because we have to serve > 150,000 simultaneous users. node.js doesn't quite do that :-)
1

Share this post


Link to post
Share on other sites

But meteor requires a meteor server. I understood a php backend is required. firebase uses the firebase service and you can use any backend you like.

0

Share this post


Link to post
Share on other sites

meteor requires a meteor server


No, the whole point of Meteor is that it runs anywhere there is node.js servers. Which is many hosting places.

If all you get is PHP, then neither Meteor nor FireBase will work, because PHP hosting doesn't allow persistent processes, period -- so you have to do (long) polling.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0