//This is if you are using Composer, your path will be diferent, change it!
require_once '../ratchet/vendor/autoload.php';
use Symfony\Component\HttpFoundation\Cookie;use Symfony\Component\HttpFoundation\Session\Session;use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
$pdo = new PDO('mysql:host=localhost;dbname=DATABASE_NAME', 'MYSQL_USER', 'MYSQL_PASSWORD',array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbOptions = array( 'db_table' => 'TABLE_NAME',
'db_id_col' => 'session_id', 'db_data_col' => 'session_value', 'db_time_col' => 'session_time',);
$storage = new NativeSessionStorage(array(), new PdoSessionHandler($pdo,$dbOptions));$session = new Session($storage);
//Here is the interesting part, i am getting the id and username from my mysql, and setting on the Symfony Session
$session->set('admin_id',$login->getUser_Id());$session->set('username',$login->getUsername());
public function onOpen(ConnectionInterface $conn) {
$Admin_Id = $conn->Session->get('admin_id');
if(isset($Admin_Id) && !empty($Admin_Id)){ $this->IdAdmin_WebSid[$Admin_Id] = $conn->resourceId; echo "Nova Conexao ADMIN! ({$conn->resourceId})\n";
//Initializing Symphony Session
$session = new Session($storage);
//Now session is initialized and my code does not need to call session_start();
//Initializing my Login code without session_start()
$login = new Login();
$session->getRequest()->getSession();
$session = new Session();
$session->start();
$session =getRequest()->getSession();
$session = new Session();
$session->start();
<?phprequire dirname(__DIR__) . '/vendor/autoload.php';use App\App1;use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler;use Ratchet\Session\SessionProvider;$pusher = new App1;$memcached = new Memcached();$memcached->addServer("127.0.0.1", 11211);$session = new SessionProvider($pusher, new MemcachedSessionHandler($memcached));
$loop = React\EventLoop\Factory::create();
$context = new React\ZMQ\Context($loop);$pull = $context->getSocket(ZMQ::SOCKET_PULL);$pull->bind('tcp://127.0.0.1:5555');$pull->on('message', array($pusher, 'onBlogEntry'));
$webSock = new React\Socket\Server($loop);$webSock->listen(8080, '127.0.0.1');
$webServer = new Ratchet\Server\IoServer( new Ratchet\Http\HttpServer( new Ratchet\WebSocket\WsServer( new Ratchet\Wamp\WampServer( $pusher ), ) ), $webSock);echo "Server is running\n";$loop->run();
php.ini
directive session.auto_start = 1
php.ini
, in the webserver directives or in .htaccess
.// session_start();
//Initializing Symphony Session
$session = new Session($storage);
session.cookie_domain = ".site.com.br"
Hi !
See the example in socketo.me/docs/push
--
---
You received this message because you are subscribed to a topic in the Google Groups "Ratchet" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ratchet-php/rTOspZU7IZE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ratchet-php...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mail: Khawlag...@gmail.com
Post the errors/problems that you have trying the example.
We will be glad to help!
Post the errors/problems that you have trying the example.
We will be glad to help!
Em 18/06/2015 04:39, "khawla gammoudi" <khawlag...@gmail.com> escreveu: