gintonicweb/websockets

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (dev-master) of this package.

Websockets plugin for CakePHP

Installs: 783

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:cakephp-plugin

dev-master 2015-12-21 22:50 UTC

This package is not auto-updated.

Last update: 2019-02-20 18:39:25 UTC


README

This is a very early work in progress. Do not use.

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require gintonicweb/websockets

Add the following to your bootstrap.php file

Controller setup

Load the websockets component in the Controller of your choice

$this->loadComponent('Websockets.Websocket');

When an actoin is trigged via regular http, it can in turn push data to the targeted users registered via websockets. Use the _ws keyword to define the wbsocket content and the options users and data

$this->set('_ws', [
    'users' => $this->Users->find()->all()->toArray(),
    'data' => $message->toArray()
]);

Authenticating users

TODO (override src/Websocket/UserDb)

Runnin the websocket server

You can use systemd to use the websocket server as a linux service. Create the file /etc/systemd/system/wsserver.service with the following content

[Unit]
Description=Websockets Server

[Service]
ExecStart=/bin/sh -c "cd /var/www/YOURAPP && vendor/bin/wsserver"

[Install]
WantedBy=multi-user.target

then run the following commands

systemctl enable wsserver.service
systemctl start wsserver.service