Start ratchet web server in codeginiter |
Hello
What is correct way to start ratchet web socket server in codeigniter? I tried Events.php file and events pre_system an post_system, but codeigniter becomes unresponsive My Code $SocketServer = null; Events::on('post_system', function () { $SocketServer = IoServer::factory( new HttpServer( new WsServer( new \ServerEvents\Chat\Chat() ) ), 6745 ); $SocketServer->run(); });
IoServer can't be run within a PHP-website, you need to start it as a service*, please read their documentation.
http://socketo.me/docs/hello-world * from the command line.
Thank you
Is there any library that enables websocket functionality in codeigniter? Could you recommend the one?
I have never developed a websocket in PHP. If we take one step back, how did you start the websocket after you have put that code into CodeIgniter?
Hello
(late but because i found this thread when i do a chat, perhaps it is gonna help others) as @jreklund said the webSocket server is independant and must be run as a service from the command line. The goal is to use codeIgniter in the websocket server and not the socket server in codeIgniter to access codeIgniter functionalities from the socket server, what i did is partially copying the index.php of the public folder of codeIgniter. The idea is : Load the app but do not run it and then you can access all the helpers then Libraries, Models & Entities . Controllers are made to work with the incoming request, so i think we should not try to call codeigniter's controllers from another PHP script. i called this file codeigniter.php : PHP Code: <?php and then in the code of the webSocket server (or whatever) : PHP Code: require "codeigniter.php" |
Welcome Guest, Not a member yet? Register Sign In |