Get support for WyriHaximus/RatchetModelPush
If you're new to LTH, please see our FAQ for more information on what it is we do.
Support Options
Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:
View Open IssuesTake a look to see if anyone else has experienced the same issue as you and if they managed to solve it.
Open an IssueMake sure to read any relevant guidelines for opening issues on this repo before posting a new issue.
Sponsor directlyCheck out the page and see if there are any options to sponsor this project or it's developers directly.
WyriHaximus/RatchetModelPush
RatchetModelPush
Model Push for the CakePHP Ratchet plugin.
What is Ratchet
Ratchet for CakePHP brings the Ratchet websocket server to CakePHP. Websockets allow you to utilize near-real-time communication between your application and it's visitors. For example notifying a page the associated record in the database has been updated using the Pushable behaviour.
Getting started
1. Requirements
This plugin depends on the following plugins and their dependencies and are pulled in by composer later on:
2. Composer
Make sure you have composer installed and configured with the autoloader registering during bootstrap as described here. Make sure you have a composer.json and add the following to your required section.
composer require wyrihaximus/ratchet-model-push
When you've set everything up, run composer install
.
3. Setup the plugin
Make sure you load RatchetModelPush
and all the plugins it depends on and their dependecies in your bootstrap and set then up properly.
4. Setting up the behavior
The following code example attaches the Pushable behavior to the WyriProject
model. The events do the following in order:
- Fires on creating on a new record and binds to
WyriProject.created
. - Fires on updating any record and binds to
WyriProject.updated
. - Fires on any updating record and binds to
WyriProject.updated.{id}
where{id}
is theid
for that record. So ifid
is1
it binds toWyriProject.updated.1
.
The data is passed into the event as a 1 dimensional array.
<?php
class Model extends AppModel {
public $actsAs = array(
'RatchetModelPush.Pushable' => array(
'events' => array(
array(
'eventName' => 'WyriProject.created',
'created' => true,
),
array(
'eventName' => 'WyriProject.updated',
'created' => false,
),
array(
'eventName' => 'WyriProject.updated.{id}',
'created' => false,
'fields' => true,
),
),
),
);
}
5. Client side
On the client side the only thing required is subscribing to the event:
cakeWamp.subscribe('Rachet.WampServer.ModelUpdate.WyriProject.updated.1', function(topicUri, event) {
// Do your stuff with the data
});
Note: the actual event you're subscribing to is prefixed by Rachet.WampServer.ModelUpdate.
.
Make sure to include the JavaScript file and its dependencies in your view:
echo $this->Html->script(array(
'Ratchet.when/when',
'Ratchet.autobahn/autobahn',
'Ratchet.cake-wamp'
));
Plugin License
(The MIT License)
Copyright © 2012 - 2013 Cees-Jan Kiewiet
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Our Mission
We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.
From the Blog
Interesting Articles
-
Generating income from open source
Jun 23 • 8 min read
-
2023 State of OSS
Apr 23 • 45 min read ★
-
A funding experiment...
Aug 19 • 10 min read
-
But You Said I could
Aug 19 • 2 min read
Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated
p-e622a1a2