|
1 |
| -PHP WebSocket |
2 |
| -============= |
3 |
| -A websocket server implemented in php. |
| 1 | +<!-- vim: set tw=79 sw=4 ts=4 et ft=markdown : --> |
| 2 | +# PHP WebSocket |
| 3 | +## Simple WebSocket server for PHP |
4 | 4 |
|
5 |
| -- Supports websocket draft hybi-10,13 (Currently tested with Chrome 18 and Firefox 11). |
| 5 | +Version: **1.0.0** |
| 6 | + |
| 7 | +A simple websocket server for PHP 5.3, using streams. |
| 8 | + |
| 9 | +### Features |
| 10 | + |
| 11 | +- Supports websocket draft hybi-10,13 (Currently tested with Chrome 18 and |
| 12 | + Firefox 11). |
6 | 13 | - Supports origin-check.
|
7 | 14 | - Supports various security/performance settings.
|
8 | 15 | - Supports binary frames. (Currently receive only)
|
9 | 16 | - Supports wss. (Needs valid certificate in Firefox.)
|
10 |
| -- Application module, the server can be extended by custom behaviors. |
11 | 17 |
|
12 |
| -## Bugs/Todos/Hints |
13 |
| -- Add support for fragmented frames. |
14 | 18 |
|
15 |
| -## Server example |
| 19 | +### Backward compatibility |
| 20 | + |
| 21 | +The public API of the server should remain compatible with early versions of |
| 22 | +php-websocket. The WebSocket namespace begins in the `/server/lib` directory. |
| 23 | +The client-side libraries are deprecated and may be removed in future: the |
| 24 | +exist as an example. You're free to use whatever client-side libraries you'd |
| 25 | +like with the server. |
| 26 | + |
| 27 | +## Installation |
16 | 28 |
|
17 |
| -This creates a server on localhost:8000 with one Application that listens on `ws://localhost:8000/demo`: |
| 29 | +The library is PSR-0 compatible, with a vendor name of WebSocket (note the |
| 30 | +capital S). An SplClassLoader is bundled for convenience. |
18 | 31 |
|
19 |
| - $server = new \WebSocket\Server('127.0.0.1', 8000, false); // host,port,ssl |
| 32 | +## Usage |
20 | 33 |
|
21 |
| - // server settings: |
22 |
| - $server->setCheckOrigin(true); |
23 |
| - $server->setAllowedOrigin('foo.lh'); |
24 |
| - $server->setMaxClients(100); |
25 |
| - $server->setMaxConnectionsPerIp(20); |
26 |
| - $server->setMaxRequestsPerMinute(1000); |
| 34 | +This creates a server on 127.0.0.1:8000 with one Application that listens on |
| 35 | +`ws://localhost:8000/demo`: |
27 | 36 |
|
28 |
| - $server->registerApplication('demo', \WebSocket\Application\DemoApplication::getInstance()); |
29 |
| - $server->run(); |
| 37 | +```php |
| 38 | +// $interface, $port, $ssl |
| 39 | +$server = new \WebSocket\Server(127.0.0.1', 8000, false); |
30 | 40 |
|
31 |
| -## Libraries used |
| 41 | +// Origin checking is supported |
| 42 | +$server->setCheckOrigin(true); |
| 43 | +$server->setAllowedOrigin('example.org') |
32 | 44 |
|
33 |
| -- [SplClassLoader](http://gist.github.com/221634) by the PHP Standards Working Group |
34 |
| -- [jQuery](http://jquery.com/) |
35 |
| -- [CoffeeScript PHP] (https://github.com/alxlit/coffeescript-php) |
| 45 | +// As is basic rate limiting |
| 46 | +$server->setMaxClients(100); |
| 47 | +$server->setMaxConnectionsPerIp(20); |
| 48 | +$server->setMaxRequestsPerMinute(1000); |
| 49 | + |
| 50 | +$server->registerApplication('demo', \WebSocket\Application\DemoApplication::getInstance()); |
| 51 | +$server->run(); |
| 52 | +``` |
| 53 | +## Authors |
| 54 | + |
| 55 | +The original maintainer and author was |
| 56 | +[@nicokaiser](https://github.com/nicokaiser). Plentiful improvements were |
| 57 | +contributed by [@lemmingzshadow](https://github.com/lemmingzshadow) and |
| 58 | +[@mazhack](https://github.com/mazhack). The server is licensed under the WTFPL, |
| 59 | +a free software compatible license. |
| 60 | + |
| 61 | +## Bugs/Todos/Hints |
| 62 | + |
| 63 | +- Add support for fragmented frames. |
| 64 | +- To report issues, see the [issue tracker](https://github.com/varspool/php-websocket/issues). |
36 | 65 |
|
37 |
| -## Demo |
| 66 | +## Examples |
38 | 67 |
|
39 |
| -- Check out http://jitt.li for a sample-project using this websocket server. |
| 68 | +- [Jitt.li](http://jitt.li), a Twitter API sample project. |
0 commit comments