polygon/realtimeco

A package which provides a simple way to integrate realtime.co to your application

dev-master 2015-07-02 18:46 UTC

This package is auto-updated.

Last update: 2024-11-06 22:50:36 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

Begin by installing this package through Composer. Edit your project's composer.json file to require polygon/realtimeco.

"require": {
	"polygon/realtimeco": "dev-master"
}

Next, update Composer from the Terminal:

composer update

Once this operation completes, the next step is to add the service provider. Open config/app.php, and add a new item to the providers array.

'Poligon\Realtimeco\RealtimecoServiceProvider',

Now add the alias.

'aliases' => array(
    ...
	'Realtimeco' => 'Polygon\Realtimeco\Facades\RealtimecoFacade',
)

From the terminal run:

php artisan vendor:publish

a configuration file should be added to config/ folder, called realtimeco.php.

Set this variables in your .env file

REALTIME_URL=http://ortc-developers.realtime.co/server/2.1 REALTIME_APP_KEY=YOUR_APPLICATION_KEY REALTIME_PRIVATE_KEY=YOUR_APPLICATION_PRIVATE_KEY REALTIME_TOKEN=dummyToken

You can get this info after creating an account at: http://www.realtime.co/

Usage example

    $channel = 'my_channel';
    $permission = 'w';
    $private = 0;
    $ttl = 180000;
    $message = ['status' => 'ok', 'msg' => 'Some message'];
    $realtime = new Realtimeco(App::call('config'));
    $realtime->auth([$channel => $permission],$private,$ttl);
    $realtime->send($channel, json_encode($message));