You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Configuring the session handler will add the [`InitializeSession` middleware](/open-source/packages/websocket-server/docs/1.x/middleware/initialize-session) to the websocket server which will provide a read-only interface for the session data from your website.
@@ -45,10 +45,10 @@ By default, the session authentication provider will attempt to authenticate to
45
45
46
46
```yaml
47
47
babdev_websocket:
48
-
authentication:
49
-
providers:
50
-
session:
51
-
firewalls: ['main'] # This can be an array to specify multiple firewalls or a string when specifying a single firewall
48
+
authentication:
49
+
providers:
50
+
session:
51
+
firewalls: ['main'] # This can be an array to specify multiple firewalls or a string when specifying a single firewall
Because a Flex recipe is not published for the bundle at this time, you will need to manually configure the bundle to fully enable its features. The below example can be written to `config/packages/babdev_websocket.yaml` in your application as a starting point:
- Enable the [session authentication provider](/open-source/packages/websocketbundle/docs/1.x/authentication) and allow sessions for all firewalls
44
+
- Configure the address the server will listen to connections on using the `BABDEV_WEBSOCKET_SERVER_URI` environment variable
45
+
- Configure the router resource for the websocket server
46
+
- Configure the session handler that is used to read session data for incoming connections (for our example, we are using a PDO session handler but this can be any shared resource such as the database or Redis)
47
+
48
+
### Configuring the WebSocket Server Address
49
+
50
+
The `babdev_websocket.server.uri` configuration node is used to define what address and port the websocket server process will listen for incoming connections on. The below snippet can be added to your application's `.env` file to define a sane default for local development, which will listen for connections on localhost at port 8080:
51
+
52
+
```properties
53
+
###> babdev/websocket-bundle ###
54
+
BABDEV_WEBSOCKET_SERVER_URI=127.0.0.1:8080
55
+
###< babdev/websocket-bundle ###
56
+
```
57
+
58
+
### Configuring the WebSocket Server Router
59
+
60
+
The websocket server uses the Symfony Routing component to power its routing implementation, which requires a second router service to be configured in your application. Most of this is taken care of already in the bundle, however, you will need to add a file in your application to define the routes for the websocket server. The below example, which is based on the default `config/routes.yaml` added to applications, can be saved to your application at `config/websocket_router.yaml`:
61
+
62
+
```yaml
63
+
controllers:
64
+
resource:
65
+
path: ../src/WebSocket/
66
+
namespace: App\WebSocket
67
+
type: attribute
68
+
```
69
+
70
+
Similar to the default router configuration, this will scan for the `AsMessageHandler` attribute on classes in your `src/WebSocket` directory.
Copy file name to clipboardExpand all lines: docs/periodic-manager.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@ The `BabDev\WebSocketBundle\PeriodicManager\PeriodicManager` interface represent
4
4
5
5
Periodic managers are initialized during the `BabDev\WebSocketBundle\Event\BeforeRunServer` event and the manager is responsible for registering its actions to the event loop.
6
6
7
+
The bundle will autoconfigure periodic managers with the `babdev_websocket_server.periodic_manager` service tag, which is required to ensure managers are correctly registered.
0 commit comments