Skip to content

Commit d89d241

Browse files
Merge pull request #2866 from verycosy/get-namespace-instance
docs: get namespace instance
2 parents 5de2b86 + 5d59ceb commit d89d241

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

content/websockets/gateways.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ There are 3 useful lifecycle hooks available. All of them have corresponding int
232232

233233
> info **Hint** Each lifecycle interface is exposed from `@nestjs/websockets` package.
234234
235-
#### Server
235+
#### Server and Namespace
236236

237237
Occasionally, you may want to have a direct access to the native, **platform-specific** server instance. The reference to this object is passed as an argument to the `afterInit()` method (`OnGatewayInit` interface). Another option is to use the `@WebSocketServer()` decorator.
238238

@@ -241,6 +241,12 @@ Occasionally, you may want to have a direct access to the native, **platform-spe
241241
server: Server;
242242
```
243243

244+
Also, you can retrieve the corresponding namespace using the `namespace` attribute, as follows:
245+
246+
```typescript
247+
@WebSocketServer({ namespace: 'my-namespace' })
248+
namespace: Namespace;
249+
244250
> warning **Notice** The `@WebSocketServer()` decorator is imported from the `@nestjs/websockets` package.
245251

246252
Nest will automatically assign the server instance to this property once it is ready to use.

0 commit comments

Comments
 (0)