forked from rodgc/ngx-socket-io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and sync api wrapper (rodgc#190)
* Fix socket.of() method Socket-io's of() only exists in the server API and it returns a new instance. For client we must create a new `io()` with the URL containing the namespace. Let's do this and share instances whenever the namespace is reused. * Fix chaining methods Since we're wrapping the socket, we must return ourselves and not the internal socket. * Fix volatile usage It's a getter that toggles a flag, but then we must return the actual instance * Add return types to help users Since we're not importing socket.io-client typings, these are particularly important to avoid `any` * Add emitWithAck() * Add offAny() and offAnyOutgoing() These match onAny() and onAnyOutgoing() * Add send() Basically emit('message', ...args) * Add compress() * Add attributes * Fix connect() and disconnect() arguments According to https://github.com/socketio/socket.io/blob/main/packages/socket.io-client/lib/socket.ts and https://socket.io/docs/v4/client-api/ these functions do not receive any arguments.
- Loading branch information
Showing
2 changed files
with
130 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters