Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
webbingbrasil/core-module / Services / SocketRouter.php
Size: Mime:
<?php
/**
 * Created by PhpStorm.
 * User: danilo
 * Date: 27/07/16
 * Time: 11:43
 */

namespace Modules\Core\Services;

use Closure;
use Ratchet\App as Socket;

class SocketRouter
{

    /**
     * The route group attribute stack.
     *
     * @var array
     */
    protected static $groupStack = [];

    /**
     * Create a route group with shared attributes.
     *
     * @param  array $attributes
     * @param  \Closure $callback
     * @return void
     */
    public function add(Closure $callback)
    {
        self::$groupStack[] = $callback;
    }


    public function execute(Socket $socket)
    {
        foreach (self::$groupStack as $callback) {
            call_user_func($callback, $socket);
        }
    }
}