An open API service indexing awesome lists of open source software.

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

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