created working session and client handler w/ websocket
This commit is contained in:
@@ -21,6 +21,8 @@ class AppKernel extends Kernel
|
|||||||
new FOS\UserBundle\FOSUserBundle(),
|
new FOS\UserBundle\FOSUserBundle(),
|
||||||
new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(),
|
new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(),
|
||||||
new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(),
|
new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(),
|
||||||
|
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
|
||||||
|
new Snc\RedisBundle\SncRedisBundle(),
|
||||||
|
|
||||||
new Jotunheimr\AdminBundle\JotunheimrAdminBundle(),
|
new Jotunheimr\AdminBundle\JotunheimrAdminBundle(),
|
||||||
new Jotunheimr\UserBundle\JotunheimrUserBundle(),
|
new Jotunheimr\UserBundle\JotunheimrUserBundle(),
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ framework:
|
|||||||
trusted_proxies: ~
|
trusted_proxies: ~
|
||||||
session:
|
session:
|
||||||
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
|
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
|
||||||
handler_id: session.handler.native_file
|
# handler_id: session.handler.native_file
|
||||||
|
handler_id: session.handler.pdo
|
||||||
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
|
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
|
||||||
fragments: ~
|
fragments: ~
|
||||||
http_method_override: true
|
http_method_override: true
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ security:
|
|||||||
|
|
||||||
providers:
|
providers:
|
||||||
fos_userbundle:
|
fos_userbundle:
|
||||||
id: fos_user.user_provider.username
|
id: fos_user.user_provider.username_email
|
||||||
|
|
||||||
firewalls:
|
firewalls:
|
||||||
main:
|
main:
|
||||||
@@ -17,8 +17,6 @@ security:
|
|||||||
provider: fos_userbundle
|
provider: fos_userbundle
|
||||||
csrf_token_generator: security.csrf.token_manager
|
csrf_token_generator: security.csrf.token_manager
|
||||||
default_target_path: /admin
|
default_target_path: /admin
|
||||||
# if you are using Symfony < 2.8, use the following config instead:
|
|
||||||
# csrf_provider: form.csrf_provider
|
|
||||||
|
|
||||||
logout: true
|
logout: true
|
||||||
anonymous: true
|
anonymous: true
|
||||||
@@ -28,3 +26,4 @@ security:
|
|||||||
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/admin, role: ROLE_SUPER_ADMIN }
|
- { path: ^/admin, role: ROLE_SUPER_ADMIN }
|
||||||
|
# - { path: ^/, role: ROLE_SUPER_ADMIN }
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"symfony/symfony": "3.1.*",
|
"symfony/symfony": "3.1.*",
|
||||||
"doctrine/orm": "^2.5",
|
"doctrine/orm": "^2.5",
|
||||||
"doctrine/doctrine-bundle": "^1.6",
|
"doctrine/doctrine-bundle": "^1.6",
|
||||||
"doctrine/doctrine-cache-bundle": "^1.2",
|
"doctrine/doctrine-cache-bundle": "^1.3",
|
||||||
"symfony/swiftmailer-bundle": "^2.3",
|
"symfony/swiftmailer-bundle": "^2.3",
|
||||||
"symfony/monolog-bundle": "^2.8",
|
"symfony/monolog-bundle": "^2.8",
|
||||||
"symfony/polyfill-apcu": "^1.0",
|
"symfony/polyfill-apcu": "^1.0",
|
||||||
@@ -31,7 +31,9 @@
|
|||||||
"gos/web-socket-bundle": "^1.8",
|
"gos/web-socket-bundle": "^1.8",
|
||||||
"friendsofsymfony/user-bundle": "~2.0@dev",
|
"friendsofsymfony/user-bundle": "~2.0@dev",
|
||||||
"doctrine/doctrine-migrations-bundle": "^1.0",
|
"doctrine/doctrine-migrations-bundle": "^1.0",
|
||||||
"symfony/assetic-bundle": "^2.8"
|
"symfony/assetic-bundle": "^2.8",
|
||||||
|
"predis/predis": "^1.0",
|
||||||
|
"snc/redis-bundle": "^2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"sensio/generator-bundle": "^3.0",
|
"sensio/generator-bundle": "^3.0",
|
||||||
|
|||||||
137
composer.lock
generated
137
composer.lock
generated
@@ -4,8 +4,8 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "c2ead293f3b494da909a8b7dceff7c40",
|
"hash": "7c1e046373c318178e58c9617d9c6931",
|
||||||
"content-hash": "267bd32d13cbb40c3078bde5258afa5b",
|
"content-hash": "b09b605e8d336a4e0bf774ce6f486957",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "doctrine/annotations",
|
"name": "doctrine/annotations",
|
||||||
@@ -961,12 +961,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git",
|
"url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git",
|
||||||
"reference": "9c64d6fa7ae264828b2ec98aca847840b200bd56"
|
"reference": "4393a98891a03fb7628c546aee4e5ced699c83de"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/9c64d6fa7ae264828b2ec98aca847840b200bd56",
|
"url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/4393a98891a03fb7628c546aee4e5ced699c83de",
|
||||||
"reference": "9c64d6fa7ae264828b2ec98aca847840b200bd56",
|
"reference": "4393a98891a03fb7628c546aee4e5ced699c83de",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1030,7 +1030,7 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"User management"
|
"User management"
|
||||||
],
|
],
|
||||||
"time": "2016-10-14 20:44:45"
|
"time": "2016-10-17 07:51:36"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gos/pnctl-event-loop-emitter",
|
"name": "gos/pnctl-event-loop-emitter",
|
||||||
@@ -1929,16 +1929,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "paragonie/random_compat",
|
"name": "paragonie/random_compat",
|
||||||
"version": "v2.0.2",
|
"version": "v2.0.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/paragonie/random_compat.git",
|
"url": "https://github.com/paragonie/random_compat.git",
|
||||||
"reference": "088c04e2f261c33bed6ca5245491cfca69195ccf"
|
"reference": "c0125896dbb151380ab47e96c621741e79623beb"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/088c04e2f261c33bed6ca5245491cfca69195ccf",
|
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/c0125896dbb151380ab47e96c621741e79623beb",
|
||||||
"reference": "088c04e2f261c33bed6ca5245491cfca69195ccf",
|
"reference": "c0125896dbb151380ab47e96c621741e79623beb",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1973,7 +1973,57 @@
|
|||||||
"pseudorandom",
|
"pseudorandom",
|
||||||
"random"
|
"random"
|
||||||
],
|
],
|
||||||
"time": "2016-04-03 06:00:07"
|
"time": "2016-10-17 15:23:22"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "predis/predis",
|
||||||
|
"version": "v1.1.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nrk/predis.git",
|
||||||
|
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
|
||||||
|
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.9"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.8"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-curl": "Allows access to Webdis when paired with phpiredis",
|
||||||
|
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Predis\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Daniele Alessandri",
|
||||||
|
"email": "suppakilla@gmail.com",
|
||||||
|
"homepage": "http://clorophilla.net"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Flexible and feature-complete Redis client for PHP and HHVM",
|
||||||
|
"homepage": "http://github.com/nrk/predis",
|
||||||
|
"keywords": [
|
||||||
|
"nosql",
|
||||||
|
"predis",
|
||||||
|
"redis"
|
||||||
|
],
|
||||||
|
"time": "2016-06-16 16:22:20"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/cache",
|
"name": "psr/cache",
|
||||||
@@ -2355,6 +2405,71 @@
|
|||||||
"description": "A security checker for your composer.lock",
|
"description": "A security checker for your composer.lock",
|
||||||
"time": "2016-09-23 18:09:57"
|
"time": "2016-09-23 18:09:57"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "snc/redis-bundle",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/snc/SncRedisBundle.git",
|
||||||
|
"reference": "b8aa1a966b32c4fba6b7dac4532d5eeb1d890afb"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/snc/SncRedisBundle/zipball/b8aa1a966b32c4fba6b7dac4532d5eeb1d890afb",
|
||||||
|
"reference": "b8aa1a966b32c4fba6b7dac4532d5eeb1d890afb",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.3",
|
||||||
|
"symfony/framework-bundle": "^2.7 || ^3.0",
|
||||||
|
"symfony/yaml": "^2.7 || ^3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/cache": "1.*",
|
||||||
|
"phpunit/phpunit": "4.8.*",
|
||||||
|
"predis/predis": "^1.0",
|
||||||
|
"symfony/console": "^2.7 || ^3.0",
|
||||||
|
"symfony/phpunit-bridge": "^2.7 || ^3.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"monolog/monolog": "If you want to use the monolog redis handler.",
|
||||||
|
"predis/predis": "If you want to use predis.",
|
||||||
|
"symfony/console": "If you want to use commands to interact with the redis database"
|
||||||
|
},
|
||||||
|
"type": "symfony-bundle",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Snc\\RedisBundle\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Henrik Westphal",
|
||||||
|
"email": "henrik.westphal@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Community contributors",
|
||||||
|
"homepage": "https://github.com/snc/SncRedisBundle/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A Redis bundle for Symfony",
|
||||||
|
"homepage": "https://github.com/snc/SncRedisBundle",
|
||||||
|
"keywords": [
|
||||||
|
"nosql",
|
||||||
|
"redis",
|
||||||
|
"symfony"
|
||||||
|
],
|
||||||
|
"time": "2016-06-17 11:50:26"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "swiftmailer/swiftmailer",
|
"name": "swiftmailer/swiftmailer",
|
||||||
"version": "v5.4.3",
|
"version": "v5.4.3",
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Mine\SeekerBundle\EventListener;
|
||||||
|
|
||||||
|
use Gos\Bundle\WebSocketBundle\Event\ClientEvent;
|
||||||
|
use Gos\Bundle\WebSocketBundle\Event\ClientErrorEvent;
|
||||||
|
use Gos\Bundle\WebSocketBundle\Event\ServerEvent;
|
||||||
|
use Gos\Bundle\WebSocketBundle\Event\ClientRejectedEvent;
|
||||||
|
|
||||||
|
class AcmeClientEventListener
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Called whenever a client connects
|
||||||
|
*
|
||||||
|
* @param ClientEvent $event
|
||||||
|
*/
|
||||||
|
public function onClientConnect(ClientEvent $event)
|
||||||
|
{
|
||||||
|
$conn = $event->getConnection();
|
||||||
|
|
||||||
|
echo $conn->resourceId . " connected" . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called whenever a client disconnects
|
||||||
|
*
|
||||||
|
* @param ClientEvent $event
|
||||||
|
*/
|
||||||
|
public function onClientDisconnect(ClientEvent $event)
|
||||||
|
{
|
||||||
|
$conn = $event->getConnection();
|
||||||
|
|
||||||
|
echo $conn->resourceId . " disconnected" . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called whenever a client errors
|
||||||
|
*
|
||||||
|
* @param ClientErrorEvent $event
|
||||||
|
*/
|
||||||
|
public function onClientError(ClientErrorEvent $event)
|
||||||
|
{
|
||||||
|
$conn = $event->getConnection();
|
||||||
|
$e = $event->getException();
|
||||||
|
|
||||||
|
echo "connection error occurred: " . $e->getMessage() . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called whenever server start
|
||||||
|
*
|
||||||
|
* @param ServerEvent $event
|
||||||
|
*/
|
||||||
|
public function onServerStart(ServerEvent $event)
|
||||||
|
{
|
||||||
|
$event = $event->getEventLoop();
|
||||||
|
|
||||||
|
echo 'Server was successfully started !' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called whenever client is rejected by application
|
||||||
|
*
|
||||||
|
* @param ClientRejectedEvent $event
|
||||||
|
*/
|
||||||
|
public function onClientRejected(ClientRejectedEvent $event)
|
||||||
|
{
|
||||||
|
$origin = $event->getOrigin;
|
||||||
|
|
||||||
|
echo 'connection rejected from ' . $origin . PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +1,44 @@
|
|||||||
|
# PDO Session Handler Configuration !!!!! --> moved to main config.yml
|
||||||
|
#framework:
|
||||||
|
# session:
|
||||||
|
# handler_id: session.handler.pdo
|
||||||
|
|
||||||
|
# Doctrine cache
|
||||||
|
doctrine_cache:
|
||||||
|
providers:
|
||||||
|
redis_cache:
|
||||||
|
redis:
|
||||||
|
host: localhost
|
||||||
|
port: 6379
|
||||||
|
database: 3
|
||||||
|
websocket_cache_client:
|
||||||
|
type: redis
|
||||||
|
alias: gos_web_socket.client_storage.driver.redis
|
||||||
|
|
||||||
|
# SNC
|
||||||
|
snc_redis:
|
||||||
|
clients:
|
||||||
|
cache:
|
||||||
|
type: predis
|
||||||
|
alias: cache
|
||||||
|
dsn: redis://localhost/2
|
||||||
|
logging: "%kernel.debug%"
|
||||||
|
options:
|
||||||
|
profile: 2.2
|
||||||
|
connection_timeout: 10
|
||||||
|
read_write_timeout: 30
|
||||||
|
|
||||||
# Web Socket Configuration
|
# Web Socket Configuration
|
||||||
gos_web_socket:
|
gos_web_socket:
|
||||||
# for user ex.: var _WS_URI = "ws://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}";
|
|
||||||
shared_config: false
|
|
||||||
server:
|
server:
|
||||||
port: 8080 # The port the socket server will listen on
|
host: 0.0.0.0
|
||||||
host: 127.0.0.1 # The host IP to bind to
|
port: 8080
|
||||||
router:
|
router:
|
||||||
resources:
|
resources:
|
||||||
- "@MineSeekerBundle/Resources/config/pubsub/routing.yml"
|
- "@MineSeekerBundle/Resources/config/pubsub/routing.yml"
|
||||||
client:
|
client:
|
||||||
firewall: secured_area # Can be an array of firewalls
|
firewall: main
|
||||||
session_handler: "@session.handler.pdo"
|
session_handler: "@session.handler.pdo"
|
||||||
# storage:
|
storage:
|
||||||
# driver: "@gos_web_socket.client_storage.driver.predis"
|
driver: "@gos_web_socket.client_storage.driver.predis"
|
||||||
# driver: "@gos_web_socket.server.in_memory.client_storage.driver"
|
decorator: "@gos_web_socket.client_storage.doctrine.decorator"
|
||||||
# ttl: 28800 # (optionally) time to live if you use redis driver
|
|
||||||
# prefix: client # (optionally) prefix if you use redis driver, create key "client:1" instead key "1"
|
|
||||||
|
|
||||||
# PDO Session Handler Configuration
|
|
||||||
framework:
|
|
||||||
session:
|
|
||||||
handler_id: session.handler.pdo
|
|
||||||
#
|
|
||||||
|
|||||||
@@ -1,27 +1,48 @@
|
|||||||
services:
|
services:
|
||||||
# mine_seeker.example:
|
|
||||||
# class: Mine\SeekerBundle\Example
|
pdo:
|
||||||
# arguments: ["@service_id", "plain_value", %parameter%]
|
class: PDO
|
||||||
|
arguments:
|
||||||
|
dsn: "mysql:host=%database_host%;dbname=%database_name%"
|
||||||
|
user: "%database_user%"
|
||||||
|
passwd: "%database_password%"
|
||||||
|
calls:
|
||||||
|
- [ setAttribute, [3, 2] ] # \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION
|
||||||
|
|
||||||
session.handler.pdo:
|
session.handler.pdo:
|
||||||
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
|
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
|
||||||
arguments:
|
public: false
|
||||||
- "mysql:dbname=%database_name%"
|
arguments: ["@pdo", {lock_mode: 0}]
|
||||||
- { db_table: sessions, db_username: myuser, db_password: mypassword }
|
|
||||||
|
|
||||||
# gos_web_scocket.client_storage.driver.predis:
|
# config.yml --> gos_web_socket > storage > client > driver
|
||||||
# class: Gos\Bundle\WebSocketBundle\Client\Driver\PredisDriver
|
gos_web_socket.client_storage.driver.predis:
|
||||||
# arguments:
|
class: Gos\Bundle\WebSocketBundle\Client\Driver\PredisDriver
|
||||||
# - "@cache.adapter.redis"
|
arguments:
|
||||||
|
- "@snc_redis.cache"
|
||||||
|
|
||||||
|
# config.yml --> gos_web_socket > storage > client > decorator
|
||||||
|
gos_web_socket.client_storage.doctrine.decorator:
|
||||||
|
class: Gos\Bundle\WebSocketBundle\Client\Driver\DoctrineCacheDriverDecorator
|
||||||
|
arguments:
|
||||||
|
- "@doctrine_cache.providers.doctrine.orm.default_result_cache"
|
||||||
|
|
||||||
acme_hello.topic_sample_service:
|
acme_hello.topic_sample_service:
|
||||||
class: Mine\SeekerBundle\Topic\AcmeTopic
|
class: Mine\SeekerBundle\Topic\AcmeTopic
|
||||||
tags:
|
tags:
|
||||||
- { name: gos_web_socket.topic }
|
- { name: gos_web_socket.topic }
|
||||||
# arguments:
|
arguments:
|
||||||
# - { clientManipulator: "@gos_web_socket.websocket.client_manipulator" }
|
clientManipulator: "@gos_web_socket.websocket.client_manipulator"
|
||||||
|
|
||||||
acme_hello.rpc_sample_service:
|
acme_hello.rpc_sample_service:
|
||||||
class: Mine\SeekerBundle\Rpc\AcmeRpc
|
class: Mine\SeekerBundle\Rpc\AcmeRpc
|
||||||
tags:
|
tags:
|
||||||
- { name: gos_web_socket.rpc }
|
- { name: gos_web_socket.rpc }
|
||||||
|
|
||||||
|
gos_web_socket_server.client_event.listener:
|
||||||
|
class: Mine\SeekerBundle\EventListener\AcmeClientEventListener
|
||||||
|
tags:
|
||||||
|
- { name: kernel.event_listener, event: 'gos_web_socket.client_connected', method: onClientConnect }
|
||||||
|
- { name: kernel.event_listener, event: 'gos_web_socket.client_disconnected', method: onClientDisconnect }
|
||||||
|
- { name: kernel.event_listener, event: 'gos_web_socket.client_error', method: onClientError }
|
||||||
|
- { name: kernel.event_listener, event: 'gos_web_socket.server_launched', method: onServerStart }
|
||||||
|
- { name: kernel.event_listener, event: 'gos_web_socket.client_rejected', method: onClientRejected }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import GridControl from './grid/grid-control';
|
|||||||
class MineSeeker extends React.Component {
|
class MineSeeker extends React.Component {
|
||||||
/** after rendering */
|
/** after rendering */
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
var websocket = WS.connect("ws://127.0.0.1:8080");
|
var websocket = WS.connect("ws://mine.dev:8080");
|
||||||
|
|
||||||
/** session is an Autobahn JS WAMP session. */
|
/** session is an Autobahn JS WAMP session. */
|
||||||
websocket.on("socket/connect", function (session) {
|
websocket.on("socket/connect", function (session) {
|
||||||
@@ -46,7 +46,8 @@ class MineSeeker extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<GridControl ref="gridControl"/>
|
<div></div>
|
||||||
|
// <GridControl ref="gridControl"/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Mine\SeekerBundle\Topic;
|
namespace Mine\SeekerBundle\Topic;
|
||||||
|
|
||||||
//use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface;
|
use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface;
|
||||||
use Gos\Bundle\WebSocketBundle\Topic\TopicInterface;
|
use Gos\Bundle\WebSocketBundle\Topic\TopicInterface;
|
||||||
use Gos\Bundle\WebSocketBundle\Router\WampRequest;
|
use Gos\Bundle\WebSocketBundle\Router\WampRequest;
|
||||||
use Ratchet\ConnectionInterface;
|
use Ratchet\ConnectionInterface;
|
||||||
@@ -10,15 +10,18 @@ use Ratchet\Wamp\Topic;
|
|||||||
|
|
||||||
class AcmeTopic implements TopicInterface
|
class AcmeTopic implements TopicInterface
|
||||||
{
|
{
|
||||||
// protected $clientManipulator;
|
/** @var ClientManipulatorInterface */
|
||||||
//
|
protected $clientManipulator;
|
||||||
// /**
|
|
||||||
// * @param ClientManipulatorInterface $clientManipulator
|
/**
|
||||||
// */
|
* AcmeTopic constructor.
|
||||||
// public function __construct(ClientManipulatorInterface $clientManipulator)
|
*
|
||||||
// {
|
* @param $clientManipulator ClientManipulatorInterface
|
||||||
// $this->clientManipulator = $clientManipulator;
|
*/
|
||||||
// }
|
public function __construct(ClientManipulatorInterface $clientManipulator)
|
||||||
|
{
|
||||||
|
$this->clientManipulator = $clientManipulator;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will receive any Subscription requests for this topic.
|
* This will receive any Subscription requests for this topic.
|
||||||
@@ -30,12 +33,12 @@ class AcmeTopic implements TopicInterface
|
|||||||
*/
|
*/
|
||||||
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
|
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
|
||||||
{
|
{
|
||||||
// $user = $this->clientManipulator->getClient($connection);
|
/** this will broadcast the message to ALL subscribers of this topic. */
|
||||||
$user = "";
|
$user = $this->clientManipulator->getClient($connection);
|
||||||
//this will broadcast the message to ALL subscribers of this topic.
|
dump($user);
|
||||||
$topic->broadcast([
|
$topic->broadcast([
|
||||||
'msg' => $connection->resourceId . " has joined " . $topic->getId(),
|
'msg' => $connection->resourceId . " has joined " . $topic->getId(),
|
||||||
'user' => $user
|
'user' => $this->getName()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +52,9 @@ class AcmeTopic implements TopicInterface
|
|||||||
*/
|
*/
|
||||||
public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
|
public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
|
||||||
{
|
{
|
||||||
//this will broadcast the message to ALL subscribers of this topic.
|
/** this will broadcast the message to ALL subscribers of this topic. */
|
||||||
|
$user = $this->clientManipulator->getClient($connection);
|
||||||
|
dump($user);
|
||||||
$topic->broadcast(['msg' => $connection->resourceId . " has left " . $topic->getId()]);
|
$topic->broadcast(['msg' => $connection->resourceId . " has left " . $topic->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user