https://github.com/brian9206/codeigniter-ratchet-websocket-support
Enable CodeIgniter runs on Ratchet for WebSocket support
https://github.com/brian9206/codeigniter-ratchet-websocket-support
Last synced: 2 months ago
JSON representation
Enable CodeIgniter runs on Ratchet for WebSocket support
- Host: GitHub
- URL: https://github.com/brian9206/codeigniter-ratchet-websocket-support
- Owner: brian9206
- Created: 2017-03-19T05:33:03.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-19T05:34:32.000Z (about 8 years ago)
- Last Synced: 2025-02-05T19:05:11.636Z (4 months ago)
- Language: PHP
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# brian9206/codeigniter-ratchet-websocket-support
Enable CodeIgniter runs on Ratchet for WebSocket support```
composer require brian9206/codeigniter-ratchet-websocket-support
```# How to use
First, create your own WebSocketServer
```
loadController("Test");
$ctrl->test($conn);
}
public function onClose(ConnectionInterface $conn) {
parent::onClose($conn);
echo "Disconnected.\n";
}
public function onError(ConnectionInterface $conn, \Exception $e) {
parent::onError($conn, $e);
}
}
```Then, create a CLI controller in application/controllers
```
run(8087);
}
}
```After that, create a directory under application called 'wscontrollers'
and create your own WebSocket controller under wscontrollers.Please note that WebSocket controller must be named like XXXController
```
use CIRatchet\CI_WebSocketController;class TestController extends CI_WebSocketController {
public function test($conn) {
$conn->send("Test OK");
}
}
```Finally, create a shell script outside your web root directory for starting the ratchet server
```
#!/bin/sh
php public/index.php server
```Note: server is your CI_CLIController name