izumi-kun/yii2-longpoll Implements long polling connection

Yii2 longpoll

  1. Installation
  2. Basic Usage
  3. Example
  4. License

Implements long polling AJAX mechanism.

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist izumi-kun/yii2-longpoll

or add

"izumi-kun/yii2-longpoll": "~1.0.0"

to the require section of your composer.json.

Basic Usage

Controller
class SiteController extends Controller
{
    public function actions()
    {
        return [
            'polling' => [
                'class' => LongPollAction::class,
                'events' => ['eventId'],
                'callback' => [$this, 'longPollCallback'],
            ],
        ];
    }
    public function longPollCallback(Server $server)
    {
        $server->responseData = 'any data';
    }
}
View
LongPoll::widget([
    'url' => ['site/polling'],
    'events' => ['eventId'],
    'callback' => 'console.log',
]);
Model
\izumi\longpoll\Event::triggerByKey('eventId');

Example

https://github.com/Izumi-kun/yii2-longpoll-example

License

BSD-3-Clause

0 0
1 follower
173 downloads
Yii Version: 2.0
License: BSD-3-Clause
Category: Networking
Tags: ajax, longpoll
Developed by: Izumi-kun
Created on: Jun 5, 2018
Last updated: (not set)
Packagist Profile
Github Repository

Related Extensions