feat(client): add close() method to server
This commit is contained in:
+5
-2
@@ -187,14 +187,17 @@ export class Client extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listen(port, callback) {
|
listen(port, callback) {
|
||||||
this.on('raw', container => {
|
const listener = container => {
|
||||||
if(container.message === 'Message') {
|
if(container.message === 'Message') {
|
||||||
const message = Message.toObject(container.Message, { longs: String })
|
const message = Message.toObject(container.Message, { longs: String })
|
||||||
callback(BigInt(message.address), message.data)
|
callback(BigInt(message.address), message.data)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
this.on('raw', listener)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
close: () => this.removeListener('raw', listener),
|
||||||
publish: flags => this.#publish(port, flags),
|
publish: flags => this.#publish(port, flags),
|
||||||
unpublish: flags => this.#unpublish(port)
|
unpublish: flags => this.#unpublish(port)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user