nest-udp2ws-adapter
v0.2.1
Published
A Nest WebSocket adapter for relaying UDP packets to ws server
Downloads
292
Maintainers
Readme
nest-udp2ws-adapter
A Nest WebSocket adapter for relaying UDP packets to ws server
Installation
To begin using it, we first install the required dependency.
$ npm install --save @nestjs/websockets nest-udp2ws-adapter ws
$ npm install --save-dev @types/ws
Getting started
Once the installation is complete, we can set up the adapter using useWebSocketAdapter()
method:
const app = await NestFactory.create(AppModule);
app.useWebSocketAdapter(new Udp2wsAdapter(app, {
type: 'udp4',
port: 41234,
}));
The second argument of the Udp2wsAdapter
constructor is an options
object. This object may consist of seven members:
Example
A working example is available here.