PHP code example of hahadu / think-swoole-socket

1. Go to this page and download the library: Download hahadu/think-swoole-socket library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hahadu / think-swoole-socket example snippets


namespace app;
use Hahadu\ThinkSwooleSocket\subscribe\Swooleable;
class Swoole extends Swooleable{
    public function onConnect($data){
       //$this->push($data);
       //or
       //$this->websocket->push(json_encode($data));
    }
}

 [
 ...
  'websocket' => [
  ...
  'handler'       => Handler::class, //default
  ...
  'subscribe'     => [
            app\Swoole::class //because namespace app\Swoole
        ],
]
];
textmate
php think swoole start