Ratchet
所属分类:Websocket编程
开发工具:PHP
文件大小:0KB
下载次数:0
上传日期:2023-05-14 12:27:15
上 传 者:
sh-1993
说明: 异步WebSocket服务器
(Asynchronous WebSocket server)
文件列表:
CHANGELOG.md (5725, 2021-12-13)
LICENSE (1055, 2021-12-13)
Makefile (1401, 2021-12-13)
SECURITY.md (191, 2021-12-13)
composer.json (1103, 2021-12-13)
phpunit.xml.dist (703, 2021-12-13)
src/ (0, 2021-12-13)
src/Ratchet/ (0, 2021-12-13)
src/Ratchet/AbstractConnectionDecorator.php (979, 2021-12-13)
src/Ratchet/App.php (5521, 2021-12-13)
src/Ratchet/ComponentInterface.php (1238, 2021-12-13)
src/Ratchet/ConnectionInterface.php (516, 2021-12-13)
src/Ratchet/Http/ (0, 2021-12-13)
src/Ratchet/Http/CloseResponseTrait.php (669, 2021-12-13)
src/Ratchet/Http/HttpRequestParser.php (1829, 2021-12-13)
src/Ratchet/Http/HttpServer.php (1945, 2021-12-13)
src/Ratchet/Http/HttpServerInterface.php (581, 2021-12-13)
src/Ratchet/Http/NoOpHttpServerController.php (480, 2021-12-13)
src/Ratchet/Http/OriginCheck.php (1877, 2021-12-13)
src/Ratchet/Http/Router.php (3031, 2021-12-13)
src/Ratchet/MessageComponentInterface.php (111, 2021-12-13)
src/Ratchet/MessageInterface.php (402, 2021-12-13)
src/Ratchet/Server/ (0, 2021-12-13)
src/Ratchet/Server/EchoServer.php (592, 2021-12-13)
src/Ratchet/Server/FlashPolicy.php (6288, 2021-12-13)
src/Ratchet/Server/IoConnection.php (675, 2021-12-13)
src/Ratchet/Server/IoServer.php (4490, 2021-12-13)
src/Ratchet/Server/IpBlackList.php (2762, 2021-12-13)
src/Ratchet/Session/ (0, 2021-12-13)
src/Ratchet/Session/Serialize/ (0, 2021-12-13)
src/Ratchet/Session/Serialize/HandlerInterface.php (261, 2021-12-13)
src/Ratchet/Session/Serialize/PhpBinaryHandler.php (917, 2021-12-13)
src/Ratchet/Session/Serialize/PhpHandler.php (1472, 2021-12-13)
src/Ratchet/Session/SessionProvider.php (8243, 2021-12-13)
src/Ratchet/Session/Storage/ (0, 2021-12-13)
... ...
# Ratchet
[![GitHub Actions][GA Image]][GA Link]
[![Autobahn Testsuite](https://img.shields.io/badge/Autobahn-passing-brightgreen.svg)](http://socketo.me/reports/ab/index.html)
[![Latest Stable Version](https://poser.pugx.org/cboden/ratchet/v/stable.png)](https://packagist.org/packages/cboden/ratchet)
A PHP library for asynchronously serving WebSockets.
Build up your application through simple interfaces and re-use your application without changing any of its code just by combining different components.
## Requirements
Shell access is required and root access is recommended.
To avoid proxy/firewall blockage it's recommended WebSockets are requested on port 80 or 443 (SSL), which requires root access.
In order to do this, along with your sync web stack, you can either use a reverse proxy or two separate machines.
You can find more details in the [server conf docs](http://socketo.me/docs/deploy#server_configuration).
### Documentation
User and API documentation is available on Ratchet's website: http://socketo.me
See https://github.com/cboden/Ratchet-examples for some out-of-the-box working demos using Ratchet.
Need help? Have a question? Want to provide feedback? Write a message on the [Google Groups Mailing List](https://groups.google.com/forum/#!forum/ratchet-php).
---
### A quick example
```php
clients = new \SplObjectStorage;
}
public function onOpen(ConnectionInterface $conn) {
$this->clients->attach($conn);
}
public function onMessage(ConnectionInterface $from, $msg) {
foreach ($this->clients as $client) {
if ($from != $client) {
$client->send($msg);
}
}
}
public function onClose(ConnectionInterface $conn) {
$this->clients->detach($conn);
}
public function onError(ConnectionInterface $conn, \Exception $e) {
$conn->close();
}
}
// Run the server application through the WebSocket protocol on port 8080
$app = new Ratchet\App('localhost', 8080);
$app->route('/chat', new MyChat, array('*'));
$app->route('/echo', new Ratchet\Server\EchoServer, array('*'));
$app->run();
```
$ php chat.php
```javascript
// Then some JavaScript in the browser:
var conn = new WebSocket('ws://localhost:8080/echo');
conn.onmessage = function(e) { console.log(e.data); };
conn.onopen = function(e) { conn.send('Hello Me!'); };
```
[GA Image]: https://github.com/ratchetphp/Ratchet/workflows/CI/badge.svg
[GA Link]: https://github.com/ratchetphp/Ratchet/actions?query=workflow%3A%22CI%22+branch%3Amaster
近期下载者:
相关文件:
收藏者: