SKPHP1989 / phpws

Automatically exported from code.google.com/p/phpws
0 stars 0 forks source link

How to broadcast messages to all users? #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi I saw your project, and I am testing something. I use your test file: 
function test_echoResourceHandlerResponse()

What I want to do:

1. I have a screen (like the client.html) with a textbox;
2. I want to do a PHP request to the socket-server (ex. 
ws://127.0.0.1:12345/echo/) with a little text;
3. I want that to show up in the client.html screen...
4. It is just one-way traffic (no user input, client.html only gets data from a 
php-request).

Is this possible? 

Original issue reported on code.google.com by mvugteveen on 1 Sep 2011 at 6:33

GoogleCodeExporter commented 8 years ago
Maybe a bit simpler:

I want to send a request via PHP (see attached file) and I want it to show on 
all connected clients...

Original comment by mvugteveen on 1 Sep 2011 at 6:41

Attachments:

GoogleCodeExporter commented 8 years ago
Ok I think I've got it....

in the file DEMO.PHP, I added this:

// Show message to all connected users
foreach ($this->users AS $user)
{
// Echo
$this->send($user, $msg->getData());
}

Original comment by mvugteveen on 1 Sep 2011 at 7:26

GoogleCodeExporter commented 8 years ago
That seems right :) Sorry for the lack of proper documentation, project is 
still young and its my first opensource project.

I will try to add some more examples (maybe in form of unittests) in the next 
few days.

Original comment by ch...@devristo.com on 2 Sep 2011 at 2:01

GoogleCodeExporter commented 8 years ago
Could you please use UNIX line endings (LF)? You use Windows line-endings... 
When I try to convert it to Unix the whole PHP script doesn't work anymore... 
Maybe you could try it?

Thanks!

Original comment by mvugteveen on 2 Sep 2011 at 5:04

GoogleCodeExporter commented 8 years ago
UNIX line endings are now used in the trunk. You can do a check out, API has 
changed as well since the 0.1a release.

Original comment by ch...@devristo.com on 3 Sep 2011 at 10:21