https://github.com/sinri/ark-websocket
Ark WebSocket Component
https://github.com/sinri/ark-websocket
Last synced: about 1 year ago
JSON representation
Ark WebSocket Component
- Host: GitHub
- URL: https://github.com/sinri/ark-websocket
- Owner: sinri
- Created: 2020-05-20T07:41:12.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-29T08:21:55.000Z (almost 5 years ago)
- Last Synced: 2024-03-14T20:21:38.149Z (about 2 years ago)
- Language: PHP
- Size: 37.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ark Websocket

## Usage
### Design your own class extending ArkWebSocketWorker and Daemon
You need to design three actions when
* a new connection comes
* a new message comes
* an existed connection closed
You need to do unmask, mask and broadcast yourself inside.
Then you have to write a daemon to run in CLI mode.
You can take `test` as an example.
### Set up your daemon
Your websocket server should listen on a port,
and use a domain and path to be entrance for the frontend and the Load Balancer.
For example, your daemon, a file called `daemon.php` which runs `loop` method of `ArkWebSocketDaemon`, listens to 8000, your pages held by Nginx listens to 80,
your domain uses `web.socket.com`, and your path would be `wss://web.socket.com/wss-service`.
Your steps:
0. Deploy your site, use Nginx or so, listen on 80 or so.
1. Run your daemon.php as `php -q daemon.php`, listen on 8000 or so; you may want to use `nohup` if you need.
2. Now config your SLB (80 or 443), when domain is `web.socket.com`
1. while the path is `/wss-service`, send packages to 8000;
2. otherwise, to 80;
Over.