library pusher
OctoberCMS Pusher Integration. Provides a simple wrapper for Pusher making it easier than ever to use websockets in an October project.
clake/pusher
OctoberCMS Pusher Integration. Provides a simple wrapper for Pusher making it easier than ever to use websockets in an October project.
- Saturday, November 12, 2016
- by ShawnClake
- Repository
- 1 Watchers
- 4 Stars
- 0 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 1 Open issues
- 1 Versions
- 0 % Grown
OctoberCMS Pusher Integration
Installation
- You must first install Pusher's PHP library:
https://github.com/pusher/pusher-http-php
- Fill in the config values included with this plugin with your applicable Pusher credentails. You will need your Pusher Secret, Pusher appid, and Pusher key.
- Create an OctoberCMS page (URL: http://yoursite.com/pusher/auth) with a blank layout and only add the AuthEndpoint component included with this plugin onto that page.
- Include Pushers javascript library to your theme:
https://js.pusher.com/3.2/pusher.min.js
Usage
-
Use this JS to create a Pusher object:, (*1)
var pusher = new Pusher('YOUR_PUSHER_KEY_GOES_HERE', {
encrypted: true
});
-
Use this JS to connect to a Pusher public channel and bind to an event:, (*2)
var channel = pusher.subscribe('PUBLIC_CHANNEL_NAME');
channel.bind('test', function(data) {
console.log("Test: " + data);
});
-
Use this JS to connect and authenticate a Pusher private channel and bind to an event:, (*3)
var privateChannel = pusher.subscribe("private-PRIVATE_CHANNEL_NAME");
privateChannel.bind('test', function(data) {
console.log("PRIVATE - test: " + data);
});
-
Use this JS to connect and authenticate a Pusher presence channel and bind to an event:, (*4)
var presenceChannel = pusher.subscribe('presence-PRESENCE_CHANNEL_NAME');
presenceChannel.bind('test', function(data) {
console.log("PRESENCE - test: " + data);
});
-
Use this PHP to trigger an event to a pusher channel:, (*5)
Pusher::init()->trigger($channel_name, $event_name, $data);
dev-master
9999999-dev
OctoberCMS Pusher Integration. Provides a simple wrapper for Pusher making it easier than ever to use websockets in an October project.
Sources
Download
MIT