mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
Add support for running using deno (#362)
* Add missing CRLF line ending * Add support for running using deno Prefix node imports with "node:" and gate a socket API that is not implemented in [deno](https://deno.land) so that the library can be used there. This should not break node and doesn't in my brief testing.
This commit is contained in:
parent
150fa0035f
commit
01794f6339
11 changed files with 32 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { createSocket } from 'dgram'
|
||||
import { createSocket } from 'node:dgram'
|
||||
import { debugDump } from './HexUtil.js'
|
||||
import { promisify } from 'util'
|
||||
import { promisify } from 'node:util'
|
||||
import Logger from './Logger.js'
|
||||
|
||||
export default class GlobalUdpSocket {
|
||||
|
|
@ -18,7 +18,10 @@ export default class GlobalUdpSocket {
|
|||
type: 'udp4',
|
||||
reuseAddr: true
|
||||
})
|
||||
udpSocket.unref()
|
||||
// https://github.com/denoland/deno/issues/20138
|
||||
if (typeof Deno === "undefined") {
|
||||
udpSocket.unref();
|
||||
}
|
||||
udpSocket.on('message', (buffer, rinfo) => {
|
||||
const fromAddress = rinfo.address
|
||||
const fromPort = rinfo.port
|
||||
|
|
@ -59,7 +62,7 @@ export default class GlobalUdpSocket {
|
|||
this.debuggingCallbacks.add(callback)
|
||||
this.logger.debugEnabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeCallback (callback) {
|
||||
this.callbacks.delete(callback)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue