https://github.com/cseufert/php-socket
A PHP Comet Library with Fallbacks
https://github.com/cseufert/php-socket
Last synced: 21 days ago
JSON representation
A PHP Comet Library with Fallbacks
- Host: GitHub
- URL: https://github.com/cseufert/php-socket
- Owner: cseufert
- Created: 2013-11-08T00:13:33.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-11-08T00:19:29.000Z (over 11 years ago)
- Last Synced: 2025-03-13T04:41:26.927Z (4 months ago)
- Size: 84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
php-socket
==========A PHP Comet Library
An example of how to use (server):
daemon.php
```php
on('connection', function($client) {
$client->raise('ping');
$client->on('pong', function($data) {
if($data['clientid'] == $client->id) {
// Connection OK!
});
});
```You can also send messages to clients outside an active comet session:
```php
getClient(123); // Client ID is 123 here
$client->raise('message', ['message'=>$message]);
```comet.php
```php
process();
```And an example of the JavaScript code:
```javascript
comet.on('ping', function(data) {
comet.raise('pong', {'clientid': comet.client.id});
});
comet.on('message', function(data) {
console.log("Message received: " + data['message']);
});
comet.start({'server': '/comet.php', 'clientid': 123});
```