Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssociate it to a controller #4

Open
KokeroO opened this issue Sep 4, 2021 · 4 comments
Open

ssociate it to a controller #4

KokeroO opened this issue Sep 4, 2021 · 4 comments

Comments

@KokeroO
Copy link

KokeroO commented Sep 4, 2021

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

@KokeroO
Copy link
Author

KokeroO commented Sep 4, 2021

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.

@hiagofullstack
Copy link

Hello friend, have you made it yet?

@KokeroO
Copy link
Author

KokeroO commented Nov 20, 2023 via email

@takielias
Copy link
Owner

@KokeroO Did you check the Example Project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants