Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Commit

Permalink
Do not store sessions in the WsServer
Browse files Browse the repository at this point in the history
  • Loading branch information
CupOfTea696 committed May 7, 2015
1 parent 755226e commit 4fe4998
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/Server/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class Dispatcher implements DispatcherContract

protected $output;

protected $sessions = [];

/**
* Create a new Dispatcher instance.
*
Expand Down Expand Up @@ -229,7 +227,6 @@ public function onOpen(Connection $connection)
public function onClose(Connection $connection)
{
$sessionId = $this->getSessionIdFromCookie($connection);
$this->forgetSession($sessionId);

$this->output->writeln("<info>Connection from <comment>[$sessionId]</comment> closed.</info>");
}
Expand All @@ -252,28 +249,15 @@ protected function loadSession(Connection $connection)
{
$sessionId = $connection->session = $this->getSessionIdFromCookie($connection);

if (array_get($this->sessions, $sessionId))
return WsSession::swap($this->sessions[$sessionId]);

$session = clone $this->Session;
$session->setId($sessionId);
$session->start();

$this->sessions[$sessionId] = (new ReadOnly(config('session.cookie')))->initialize($session->all(), $sessionId);
WsSession::swap($this->sessions[$sessionId]);
$readonly = (new ReadOnly(config('session.cookie')))->initialize($session->all(), $sessionId);
WsSession::swap($readonly);
unset($session);
}

/**
* Remove Session from stored sessions
*
* @param string $sessionId
* @return void
*/
protected function forgetSession($sessionId){
array_forget($this->sessions, $sessionId);
}

/**
* Build an \Illuminate\Http\Request object
*
Expand Down

0 comments on commit 4fe4998

Please sign in to comment.