Skip to content

Commit

Permalink
Merge pull request #275 from ecmchow/master
Browse files Browse the repository at this point in the history
Corrected Socket.php and improve README
  • Loading branch information
walkor authored Apr 7, 2022
2 parents a5758da + 708afb9 commit 04e8b8a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
A server side alternative implementation of [socket.io](https://github.com/socketio/socket.io) in PHP based on [Workerman](https://github.com/walkor/Workerman).<br>

# Notice
Only support socket.io v1.3.0 or greater. <br>
Only support socket.io >= v1.3.0 and <= v2.x <br>
This project is just translate socket.io by [workerman](https://github.com/walkor/Workerman).<br>
More api just see http://socket.io/docs/server-api/
More api just see [https://socket.io/docs/v2/server-api/](https://socket.io/docs/v2/server-api/)

# Install
composer require workerman/phpsocket.io
Expand Down Expand Up @@ -138,6 +138,28 @@ $io->on('connection', function ($connection) use ($io) {
Worker::runAll();
```

## Acknowledgement callback
```php

use Workerman\Worker;
use PHPSocketIO\SocketIO;

require_once __DIR__ . '/vendor/autoload.php';

$io = new SocketIO(2021);

$io->on('connection', function ($connection) use ($io) {
$socket->on('message with ack', function ($data, $callback) use ($socket, $io) {
// acknowledgement callback
if ($callback && is_callable($callback)) {
$callback(0);
}
});
});

Worker::runAll();
```

# 手册
[中文手册](https://github.com/walkor/phpsocket.io/tree/master/docs/zh)

Expand Down
2 changes: 1 addition & 1 deletion src/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public function onack($packet)
call_user_func($ack, $packet['data']);
unset($this->acks[$packet['id']]);
} else {
echo ('bad ack '. packet.id);
echo ('bad ack '. $packet['id']);
}
}

Expand Down

0 comments on commit 04e8b8a

Please sign in to comment.