nest-udp2ws-adapter
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

nest-udp2ws-adapter

NPM version

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:

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.

License

MIT

Package Sidebar

Install

npm i nest-udp2ws-adapter

Weekly Downloads

23

Version

0.2.0

License

MIT

Unpacked Size

121 kB

Total Files

31

Last publish

Collaborators

  • chunkai1312