-
Notifications
You must be signed in to change notification settings - Fork 18
/
ChannelAuthenticator.php
47 lines (39 loc) · 1.12 KB
/
ChannelAuthenticator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
* This file is part of `Composer as a service`.
*
* (c) Pascal Borreli <pascal@borreli.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ayaline\Bundle\ComposerBundle\Pusher;
use Lopi\Bundle\PusherBundle\Authenticator\ChannelAuthenticatorInterface;
use Symfony\Component\HttpFoundation\RequestStack;
class ChannelAuthenticator implements ChannelAuthenticatorInterface
{
protected $requestStack;
/**
* Constructor.
*
* @param RequestStack $requestStack A RequestStack instance
*/
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
/**
* @param string $socketId
* @param string $channelName
*
* @return bool
*/
public function authenticate($socketId, $channelName)
{
$request = $this->requestStack->getCurrentRequest();
$session = $request->getSession();
$session->set('socketId', $socketId);
$session->set('channelName', $channelName);
return true;
}
}