codeigniter4-websocket icon indicating copy to clipboard operation
codeigniter4-websocket copied to clipboard

ssociate it to a controller

Open KokeroO opened this issue 4 years ago • 4 comments

How can I associate it to a controller that, when interacting with the controller, sends messages to all clients?

KokeroO avatar Sep 04 '21 13:09 KokeroO

namespace App\Controllers\Admin;

use CodeIgniter\API\ResponseTrait;
use WebSocket\Client;
use Takielias\CodeigniterWebsocket\Libraries\Server;
class AnprIntelbras extends \CodeIgniter\Controller
{
	use ResponseTrait;
	public $db;

	protected $configWeb;

	protected $ConnectionInterface;

	public $config = array();

	public function __construct(){
        $this->db = \Config\Database::connect();
		$this->VeiculosModel = new \App\models\VeiculosModel();
		$this->ConfigAnprModel = new \App\models\ConfigAnprModel();
		$this->configWeb = config('CodeigniterWebsocket');
    }
	
	public function test() {
		$this->client = new Client('ws://localhost:8282');
		$this->server = new Server($this->configWeb, null);
		$this->server->onMessage($this->client, 'Test');
	}

I would like that whenever I interact with this controller method it will be able to send a message. As I discover the best way to do this, I believe I will be able to adapt to my project.

KokeroO avatar Sep 04 '21 14:09 KokeroO

Hello friend, have you made it yet?

hiagodeoliveiratv avatar Nov 20 '23 14:11 hiagodeoliveiratv

Não me recordo se foi diretamente pelo codeigniter, vejo mais tarde e te retorno. Qualquer coisa me lembre via ZAP. 44 999701349

Obter o Outlook para Androidhttps://aka.ms/AAb9ysg


From: Hiago de Oliveira @.> Sent: Monday, November 20, 2023 11:58:27 AM To: takielias/codeigniter4-websocket @.> Cc: KokeroO @.>; Author @.> Subject: Re: [takielias/codeigniter4-websocket] ssociate it to a controller (#4)

Hello friend, have you made it yet?

— Reply to this email directly, view it on GitHubhttps://github.com/takielias/codeigniter4-websocket/issues/4#issuecomment-1819225443, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG7H7Q2J5TGBYR56Q76GFKDYFNVZHAVCNFSM5DNI33AKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBRHEZDENJUGQZQ. You are receiving this because you authored the thread.Message ID: @.***>

KokeroO avatar Nov 20 '23 15:11 KokeroO

@KokeroO Did you check the Example Project?

takielias avatar Nov 21 '23 01:11 takielias