services:
    gos_web_socket.authentication.authenticator:
        class: Gos\Bundle\WebSocketBundle\Authentication\Authenticator
        public: false
        arguments:
            - ~ # authentication providers, set based on configuration
            - '@gos_web_socket.authentication.token_storage'

    gos_web_socket.authentication.connection_repository:
        class: Gos\Bundle\WebSocketBundle\Authentication\ConnectionRepository
        public: false
        arguments:
            - '@gos_web_socket.authentication.token_storage'
            - '@gos_web_socket.authentication.authenticator'

    gos_web_socket.authentication.provider.session:
        class: Gos\Bundle\WebSocketBundle\Authentication\Provider\SessionAuthenticationProvider
        abstract: true
        public: false
        arguments:
            - '@gos_web_socket.authentication.token_storage'
            - ~ # firewalls, set based on configuration

    gos_web_socket.authentication.storage.driver.in_memory:
        class: Gos\Bundle\WebSocketBundle\Authentication\Storage\Driver\InMemoryStorageDriver
        public: false

    gos_web_socket.authentication.storage.driver.psr_cache:
        class: Gos\Bundle\WebSocketBundle\Authentication\Storage\Driver\PsrCacheStorageDriver
        public: false
        arguments:
            - ~ # cache pool

    gos_web_socket.authentication.token_storage:
        class: Gos\Bundle\WebSocketBundle\Authentication\Storage\TokenStorage
        public: false
        arguments:
            - '@gos_web_socket.authentication.storage.driver'

    gos_web_socket.client.authentication.websocket_provider:
        class: Gos\Bundle\WebSocketBundle\Client\Auth\WebsocketAuthenticationProvider
        public: false
        # deprecated service, deprecation is set in the container extension
        arguments:
            - '@gos_web_socket.client.storage'
            - '%gos_web_socket.firewall%'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.client.driver.doctrine_cache:
        class: Gos\Bundle\WebSocketBundle\Client\Driver\DoctrineCacheDriverDecorator
        public: false
        # deprecated service, deprecation is set in the container extension
        # arguments are set by the container extension

    gos_web_socket.client.driver.symfony_cache:
        class: Gos\Bundle\WebSocketBundle\Client\Driver\SymfonyCacheDriverDecorator
        public: false
        # deprecated service, deprecation is set in the container extension
        # arguments are set by the container extension

    gos_web_socket.client.driver.in_memory:
        class: Gos\Bundle\WebSocketBundle\Client\Driver\InMemoryDriver
        public: false
        # deprecated service, deprecation is set in the container extension

    gos_web_socket.client.manipulator:
        class: Gos\Bundle\WebSocketBundle\Client\ClientManipulator
        public: true
        # deprecated service, deprecation is set in the container extension
        arguments:
            - '@gos_web_socket.client.storage'
            - '@gos_web_socket.client.authentication.websocket_provider'
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.client.storage:
        class: Gos\Bundle\WebSocketBundle\Client\ClientStorage
        public: false
        # deprecated service, deprecation is set in the container extension
        arguments:
            - ~ # driver argument is set by the container extension
            - '%gos_web_socket.client.storage.ttl%'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.command.websocket_server:
        class: Gos\Bundle\WebSocketBundle\Command\WebsocketServerCommand
        public: false
        arguments:
            - '@gos_web_socket.server.launcher'
            - '%gos_web_socket.server.host%'
            - '%gos_web_socket.server.port%'
            - '@gos_web_socket.registry.server'
        tags:
            - { name: console.command, command: gos:websocket:server }

    gos_web_socket.data_collector.websocket:
        class: Gos\Bundle\WebSocketBundle\DataCollector\WebsocketDataCollector
        public: false
        # deprecated service, deprecation is set in the container extension
        tags:
            - { name: data_collector, template: '@GosWebSocket/Collector/websocket.html.twig', id: 'websocket' }

    gos_web_socket.dispatcher.rpc:
        class: Gos\Bundle\WebSocketBundle\Server\App\Dispatcher\RpcDispatcher
        public: true
        arguments:
            - '@gos_web_socket.registry.rpc'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: monolog.logger, channel: websocket }
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.dispatcher.topic:
        class: Gos\Bundle\WebSocketBundle\Server\App\Dispatcher\TopicDispatcher
        public: true
        arguments:
            - '@gos_web_socket.registry.topic'
            - '@gos_web_socket.topic.periodic_timer'
            - '@gos_web_socket.wamp.topic_manager'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: monolog.logger, channel: websocket }
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.event_listener.client:
        class: Gos\Bundle\WebSocketBundle\EventListener\ClientEventListener
        public: false
        arguments:
            - '@gos_web_socket.client.storage'
            - '@gos_web_socket.client.authentication.websocket_provider'
        calls:
            - [ setLogger, ['@logger'] ]
        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.client_rejected', method: onClientRejected }
            - { name: kernel.event_listener, event: 'gos_web_socket.connection_rejected', method: onConnectionRejected }
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.event_listener.close_pusher_connections:
        class: Gos\Bundle\WebSocketBundle\EventListener\ClosePusherConnectionsListener
        public: false
        # deprecated service, deprecation is set in the container extension
        arguments:
            - '@gos_web_socket.registry.pusher'
        tags:
            - { name: kernel.event_listener, event: 'kernel.terminate', method: closeConnection }

    gos_web_socket.event_listener.register_periodic_memory_timer:
        class: Gos\Bundle\WebSocketBundle\EventListener\RegisterPeriodicMemoryTimerListener
        public: false
        arguments:
            - '@gos_web_socket.registry.periodic'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: kernel.event_listener, event: 'gos_web_socket.server_launched', method: registerPeriodicHandler, priority: 255 }
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.event_listener.register_periodic_timers:
        class: Gos\Bundle\WebSocketBundle\EventListener\RegisterPeriodicTimersListener
        public: false
        arguments:
            - '@gos_web_socket.registry.periodic'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: kernel.event_listener, event: 'gos_web_socket.server_launched', method: registerPeriodics }
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.event_listener.register_push_handlers:
        class: Gos\Bundle\WebSocketBundle\EventListener\RegisterPushHandlersListener
        public: false
        # deprecated service, deprecation is set in the container extension
        arguments:
            - '@gos_web_socket.registry.server_push_handler'
            - '@gos_web_socket.server.application.wamp'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: kernel.event_listener, event: 'gos_web_socket.server_launched', method: registerPushHandlers }
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.event_listener.start_server:
        class: Gos\Bundle\WebSocketBundle\EventListener\StartServerListener
        public: false
        arguments:
            - '@gos_web_socket.registry.periodic'
            - '@gos_web_socket.registry.server_push_handler'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: kernel.event_listener, event: 'gos_web_socket.server_launched', method: bindPnctlEvent }
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.periodic_ping.doctrine:
        class: Gos\Bundle\WebSocketBundle\Periodic\DoctrinePeriodicPing
        abstract: true
        public: false
        # arguments are set by the container extension
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.periodic_ping.pdo:
        class: Gos\Bundle\WebSocketBundle\Periodic\PdoPeriodicPing
        abstract: true
        public: false
        # arguments are set by the container extension
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.periodic_ping.memory_usage:
        class: Gos\Bundle\WebSocketBundle\Periodic\PeriodicMemoryUsage
        public: false
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.pusher.amqp:
        class: Gos\Bundle\WebSocketBundle\Pusher\Amqp\AmqpPusher
        public: true
        # deprecated service, deprecation is set in the container extension
        arguments:
            - '@gos_web_socket.router.wamp'
            - '@serializer'
            - ~ # connection factory argument is set by the container extension
        tags:
            - { name: gos_web_socket.pusher, alias: amqp }

    gos_web_socket.pusher.amqp.push_handler:
        class: Gos\Bundle\WebSocketBundle\Pusher\Amqp\AmqpServerPushHandler
        # deprecated service, deprecation is set in the container extension
        arguments:
            - '@gos_web_socket.router.wamp'
            - '@serializer'
            - '@event_dispatcher'
            - ~ # connection factory argument is set by the container extension
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: gos_web_socket.push_handler, alias: amqp }
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.pusher.wamp:
        class: Gos\Bundle\WebSocketBundle\Pusher\Wamp\WampPusher
        public: true
        # deprecated service, deprecation is set in the container extension
        arguments:
            - '@gos_web_socket.router.wamp'
            - '@serializer'
            - ~ # connection factory argument is set by the container extension
        tags:
            - { name: gos_web_socket.pusher, alias: wamp }

    gos_web_socket.registry.periodic:
        class: Gos\Bundle\WebSocketBundle\Server\App\Registry\PeriodicRegistry
        public: true
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.registry.origins:
        class: Gos\Bundle\WebSocketBundle\Server\App\Registry\OriginRegistry
        public: true
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.registry.pusher:
        class: Gos\Bundle\WebSocketBundle\Pusher\PusherRegistry
        public: true
        # deprecated service, deprecation is set in the container extension

    gos_web_socket.registry.rpc:
        class: Gos\Bundle\WebSocketBundle\Server\App\Registry\RpcRegistry
        public: true
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.registry.server:
        class: Gos\Bundle\WebSocketBundle\Server\App\Registry\ServerRegistry
        public: true
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.registry.server_push_handler:
        class: Gos\Bundle\WebSocketBundle\Pusher\ServerPushHandlerRegistry
        public: true
        # deprecated service, deprecation is set in the container extension

    gos_web_socket.registry.topic:
        class: Gos\Bundle\WebSocketBundle\Server\App\Registry\TopicRegistry
        public: true
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.router.wamp:
        class: Gos\Bundle\WebSocketBundle\Router\WampRouter
        public: false
        arguments:
            - '@gos_pubsub_router.router.websocket'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.server.application.wamp:
        class: Gos\Bundle\WebSocketBundle\Server\App\WampApplication
        public: false
        arguments:
            - '@gos_web_socket.dispatcher.rpc'
            - '@gos_web_socket.dispatcher.topic'
            - '@event_dispatcher'
            - '@gos_web_socket.client.storage'
            - '@gos_web_socket.router.wamp'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.server.builder:
        class: Gos\Bundle\WebSocketBundle\Server\App\ServerBuilder
        public: false
        arguments:
            - '@gos_web_socket.server.event_loop'
            - '@gos_web_socket.wamp.topic_manager'
            - '@gos_web_socket.registry.origins'
            - '@event_dispatcher'
            - '%gos_web_socket.server.origin_check%'
            - '%gos_web_socket.server.keepalive_ping%'
            - '%gos_web_socket.server.keepalive_interval%'
            - '%gos_web_socket.server.ip_address_check%'
            - '%gos_web_socket.blocked_ip_addresses%'

    gos_web_socket.server.entry_point:
        class: Gos\Bundle\WebSocketBundle\Server\EntryPoint
        public: true
        # deprecated service, deprecation is set in the container extension
        arguments:
            - '@gos_web_socket.registry.server'

    gos_web_socket.server.launcher:
        class: Gos\Bundle\WebSocketBundle\Server\ServerLauncher
        public: true
        arguments:
            - '@gos_web_socket.registry.server'
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.server.event_loop:
        class: React\EventLoop\LoopInterface
        public: true
        factory: ['React\EventLoop\Loop', 'get']
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.server.websocket:
        class: Gos\Bundle\WebSocketBundle\Server\Type\WebSocketServer
        public: false
        arguments:
            - '@gos_web_socket.server.builder'
            - '@gos_web_socket.server.event_loop'
            - '@event_dispatcher'
            - '%gos_web_socket.server.tls.enabled%'
            - '%gos_web_socket.server.tls.options%'
        calls:
            - [ setLogger, ['@logger'] ]
        tags:
            - { name: gos_web_socket.server }
            - { name: monolog.logger, channel: websocket }

    gos_web_socket.topic.periodic_timer:
        class: Gos\Bundle\WebSocketBundle\Topic\TopicPeriodicTimer
        public: true
        arguments:
            - '@gos_web_socket.server.event_loop'
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }

    gos_web_socket.wamp.topic_manager:
        class: Gos\Bundle\WebSocketBundle\Topic\TopicManager
        public: true
        calls:
            - [ setWampApplication, ['@gos_web_socket.server.application.wamp'] ]
        tags:
            - { name: container.private, package: 'gos/web-socket-bundle', version: '3.9' }
