0.1.0 • Published 2 years ago
nest-udp-adapter
Licence
MIT
Version
0.1.0
Deps
0
Size
106 kB
Vulns
0
Weekly
0
nest-udp-adapter
A Nest UDP adapter based on @nestjs/websockets
Installation
To begin using it, we first install the required dependency.
$ npm install --save @nestjs/websockets nest-udp-adapter
Getting started
Once the installation is complete, we can set up UDP adapter using useWebSocketAdapter() method:
const app = await NestFactory.create(AppModule);
app.useWebSocketAdapter(new UdpAdapter(app, {
type: 'udp4',
port: 41234,
}));
The second argument of the UdpAdapter constructor is an options object. This object may consist of seven members:
type |
Either udp4 or udp6 (default: udp4) |
port |
Destination port |
address |
Destination host name or IP address |
socketOptions |
dgram.SocketOptions (read more here) |
bindOptions |
dgram.BindOptions (read more here) |
multicastAddress |
The IP multicast group address |
multicastInterface |
The local IP address associated with a network interface |
Example
A working example is available here.