diff --git a/CHANGELOG.md b/CHANGELOG.md index f4f3cfe..95652e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [4.5.1] - 2023-05-11 + +### Added + +- `listeners` Method. +- `listenersAny` Method. +- `listenersAnyOutgoing` Method. +- `off` Method. +- `onAny` Method. +- `onAnyOutgoing` Method. +- `prependAny` Method. +- `prependAnyOutgoing` Method. +- `timeout` Method. +- `volatile` Method. + ## [4.5.0] - 2023-05-11 ### Added diff --git a/package-lock.json b/package-lock.json index 9290499..1cf5bde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ngx-socket-io", - "version": "4.5.0", + "version": "4.5.1", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index e29a5a5..8720432 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-socket-io", - "version": "4.5.0", + "version": "4.5.1", "description": "Socket.IO module for Angular", "main": "index.ts", "scripts": { diff --git a/src/socket-io.service.ts b/src/socket-io.service.ts index e015d12..c1ea4a3 100644 --- a/src/socket-io.service.ts +++ b/src/socket-io.service.ts @@ -83,4 +83,57 @@ export class WrappedSocket { fromOneTimeEvent(eventName: string): Promise { return new Promise(resolve => this.once(eventName, resolve)); } + + listeners(eventName: string) { + return this.ioSocket.listeners(eventName); + } + + listenersAny() { + return this.ioSocket.listenersAny(); + } + + listenersAnyOutgoing() { + return this.ioSocket.listenersAnyOutgoing(); + } + + off(eventName?: string, listener?: Function[]) { + if (!eventName) { + // Remove all listeners for all events + return this.ioSocket.offAny(); + } + + if (eventName && !listener) { + // Remove all listeners for that event + return this.ioSocket.off(eventName); + } + + // Removes the specified listener from the listener array for the event named + return this.ioSocket.off(eventName, listener); + } + + onAny(callback: (event: string, ...args: any[]) => void) { + return this.ioSocket.onAny(callback); + } + + onAnyOutgoing(callback: (event: string, ...args: any[]) => void) { + return this.ioSocket.onAnyOutgoing(callback); + } + + prependAny(callback: (event: string, ...args: any[]) => void) { + return this.ioSocket.prependAny(callback); + } + + prependAnyOutgoing( + callback: (event: string | symbol, ...args: any[]) => void + ) { + return this.ioSocket.prependAnyOutgoing(callback); + } + + timeout(value: number) { + return this.ioSocket.timeout(value); + } + + volatile() { + return this.ioSocket.volatile; + } }