module.exports = app => { return { async handle(udp) { udp.on('error', (err) => { console.log(`udp error:\n${err.stack}`); }); udp.on('message', (msg, rinfo) => { //cantest接口 if (app.cantest1) { app.mqttServe.publish(`/cantest1`, msg.toString(), { qos: 2, retain: false, }) } }); udp.on('listening', () => { let address = udp.address(); console.log(`udp listening ${address.address}:${address.port}`); }); }, }; };