2017 © Pedro Peláez
 

library pusher-client

A library

image

tokenly/pusher-client

A library

  • Tuesday, February 27, 2018
  • by dweller
  • Repository
  • 3 Watchers
  • 0 Stars
  • 7,789 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 16 % Grown

The README.md

A client component for the client-side messaging pusher service., (*1)

Installation

  • composer require tokenly/pusher-client
  • Add Tokenly\PusherClient\Provider\PusherClientServiceProvider::class to the list of service providers

Environment Variables

Set the following environment variables, (*2)

  • PUSHER_SERVER_URL (optional, defaults to https://pusher.tokenly.com)
  • PUSHER_CLIENT_URL (optional, defaults to the server URL)
  • PUSHER_PASSWORD (required for Tokenly services)

Server-side Usage

Send an event

$channel = 'my-event-channel-name';
$data = json_encode(['fromUser' => 'fred', 'messageId' => 101, 'messageText' => 'hello world!']);

$pusher = app(\Tokenly\PusherClient\Client::class);
$pusher->send($channel, $data);

Client-side Usage

See the pusher-client.js example for the client javascript code., (*3)

Step 1: Include the two libraries

This is best toward the end of your body tag., (*4)

<script src="https://pusher.tokenly.com/public/client.js"></script>
<script src="/path/to/js/pusher-client.js"></script>

Step 2: Subscribe and respond to events

After the two script tags below are loaded, you can subscribe to a channel, (*5)

<script>
    var subscribedClient = PusherClient.subscribeToPusherChanel('my-event-channel-name', function(dataReceived) {
        // received a websocket message on channel /my-event-channel-name
        console.log('user '+dataReceived.fromUser+' said '+messageText);
    });
</script>

The Versions

27/02 2018

dev-master

9999999-dev

A library

  Sources   Download

MIT

The Requires

 

The Development Requires

18/04 2017

v1.1.0

1.1.0.0

A library

  Sources   Download

MIT

The Requires

 

The Development Requires

07/06 2016

v1.0.0

1.0.0.0

A library

  Sources   Download

MIT

The Requires

 

The Development Requires