HTML5 WebSockets with PHP (WAMP)

preview_player
Показать описание
This is a demo of a simple HTML5 WebSockets server implemented in PHP. Right now the server simply connects a bunch of users, received messages from each user, then broadcasts the same text to all other clients.

The server follows draft 76. I've tried several (well, only a few were available) articles and tutorials about setting up a custom PHP server, but nothing very helpful. The most helpful one was the one posted at NetTuts, but even that one could only take me so far.

My goal with this for right now, as this is part of a final project I'm working on for a Networking class, is to use the sockets to write an app that simulates stock exchange. Several users will log in and see a few companies whose stock they may purchase, then everything updates for everyone in real time.

What I'm liking about the HTML5 WebSockets is that there is absolutely no need for AJAX. With AJAX, in order for everyone to stay synchronized instantaneously, you'd have to call up the server a lot of times. With the WebSockets, the only think you have to do on your front end (client side) is set up a callback function to handle messages from the server. That's it!

I'll have a detailed tutorial on this, and on my final project once I finish it.

Рекомендации по теме
Комментарии
Автор

how about some tutorials, examples, and step by step setups with more practical applications?  chat apps is always the first thing mentioned when talking about websockets.  not everyone wants chat apps.  how about an app where it's not just new info being inputted that displays right away on multiple clients... how about an app where data that is already saved on a database is displayed and that data can edited and re-edited by multiple people on multiple computers and the new data is shown to all clients in real-time.  sort of like the dead project called Google Wave, and their current application called Google Docs where there is multi-person collaboration on the documents and everyone sees the changes made by everyone else as soon as they happen.  how about some easy to follow video lessons on that?  reading manuals and documentation to learn things is not fun or quick.  it's faster when someone explains it and shows examples and maybe even provides downloads to quickly setup a working example on your own server.

le-ar
Автор

music didden't stop when the video stopt

aysiyh
Автор

how can I use the socket?

I use wamp on windows, I was in command of the windows and typed:

c: \ wamp \ bin \ php \ php5.3.5 \ php-q server.php

and shows the error:

Fatal error: Call to undefined function socket_create ()

Abelardooliver
Автор

this sucks. i have no idea what's going on. lazy.

StevenDavisPhoto
visit shbcf.ru