Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14605
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Arno Welzel <usenet@arnowelzel.de> |
| Newsgroups | comp.lang.php |
| Subject | Re: newbie |
| Date | Tue, 18 Nov 2014 17:44:14 +0100 |
| Lines | 54 |
| Message-ID | <546B775E.50309@arnowelzel.de> (permalink) |
| References | <m3o3m5$pis$1@gregory.bnet.hr> <m3o5po$lav$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net n5Ur4xPBbWa1njc2vDwnGQCEmJeLAJRjyvI7oU6I0O+eZfAhjb |
| Cancel-Lock | sha1:2DUS3EZboB/qRNdndk7cak8OB7I= |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
| In-Reply-To | <m3o5po$lav$1@dont-email.me> |
| Xref | csiph.com comp.lang.php:14605 |
Show key headers only | View raw
Am 2014-11-09 um 17:46 schrieb Jerry Stuckle: > On 11/9/2014 11:10 AM, Haris Bogdanovich wrote: >> Hi. >> >> I made a tic-tac-toe in Javascript, it works OK and I want it online for >> two players. Do I have to rewrite it in PHP or use AJAX or some other way ? >> >> Thanks. > > No matter how you do it, you'll need something server-side to > communicate between the players. > > But HTML is not well-suited for such an operation. HTML is a > request/response protocol; when player "A" makes a move, player "B" will > have to do something to see the change - there is no way HTML can push > the change to player "B". The only way "B" can get the change is to "HTML" is no protocol at all. I assume you talk about "HTTP". > request information from the server. This can be done several ways, > such as a "refresh" button, a meta refresh in the HTML or an Ajax > request. But any way you do it will require polling the server. If you can set up your own services on the server side you can also use web sockets as most current browsers support them (see <http://caniuse.com/#search=web%20sockets>). A very simple "quick & dirty" example: <https://arnowelzel.de/tools/chat> The backend is a web socket server based on Ratchet and stunnel to handle the TLS stuff. But newer web servers like nginx can also be used as a web socket proxy - or Apache 2.4 using the mod_proxy_wstunnel module. Ajax with polling every x seconds may be a good fallback in case the browser does not support web sockets. > Another problem you'll have to handle is how to communicate between the > two players. In general, each user on a website is independent of all > other users. Again, there are several ways to do this, such as storing > the moves in a database with a game number, and associating that game > number with each player. But again, it's something you'll have to consider. Yes - at least there needs to be a list of "active games" with the connected players on the server. -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de http://fahrradzukunft.de
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
newbie Haris Bogdanovich <haris.bogdanovic@gmail.com> - 2014-11-09 17:10 +0100
Re: newbie Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-09 11:46 -0500
Re: newbie Arno Welzel <usenet@arnowelzel.de> - 2014-11-18 17:44 +0100
Re: newbie Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-18 16:07 -0500
Re: newbie Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-09 18:31 +0100
Re: newbie Luuk <luuk@invalid.lan> - 2014-11-09 18:41 +0100
Re: newbie Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-09 16:38 -0500
Re: newbie Arno Welzel <usenet@arnowelzel.de> - 2014-11-18 17:48 +0100
Re: newbie "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-18 19:00 +0100
Re: newbie Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-18 16:06 -0500
Re: newbie Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-18 22:54 +0000
Re: newbie Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-18 19:18 -0500
Re: newbie Arno Welzel <usenet@arnowelzel.de> - 2014-11-19 10:12 +0100
Re: newbie Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-19 06:37 -0500
Re: newbie Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-19 12:59 +0100
Re: newbie Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-19 10:45 -0500
Re: newbie Arno Welzel <usenet@arnowelzel.de> - 2014-11-19 17:18 +0100
Re: newbie Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-19 13:23 -0500
Re: newbie Arno Welzel <usenet@arnowelzel.de> - 2014-11-20 08:19 +0100
Re: newbie Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-20 09:01 -0500
Re: newbie Arno Welzel <usenet@arnowelzel.de> - 2014-11-19 10:11 +0100
Re: newbie Erwin Moller <erwinmollerusenet@xs4all.nl> - 2014-11-19 15:02 +0100
csiph-web