Damien Arrachequesne
0f11c4745f
chore(release): 4.4.0
...
Diff: https://github.com/socketio/socket.io/compare/4.3.2...4.4.0
4.4.0
2021-11-18 14:10:19 +01:00
Damien Arrachequesne
b839a3b400
fix: prevent double ack when emitting with a timeout
...
The ack was not properly removed upon timeout, and could be called
twice.
Related: f0ed42f18c
2021-11-18 14:03:07 +01:00
Damien Arrachequesne
f0ed42f18c
feat: add timeout feature
...
Usage:
```js
socket.timeout(5000).emit("my-event", (err) => {
if (err) {
// the client did not acknowledge the event in the given delay
}
});
```
2021-11-16 20:07:53 +01:00
Damien Arrachequesne
b7213e71e4
test: fix flaky test
...
`srv.close()` only closes the underlying HTTP server, but this does not
terminate the existing WebSocket connections.
Reference: https://nodejs.org/api/http.html#serverclosecallback
2021-11-16 15:58:55 +01:00
Damien Arrachequesne
2da82103d2
test: add test for volatile packet with binary
...
See also: 88eee5948a
2021-11-16 15:57:32 +01:00
Damien Arrachequesne
02b0f73e2c
fix: only set 'connected' to true after middleware execution
...
The Socket instance is only considered connected when the "connection"
event is emitted, and not during the middleware(s) execution.
```js
io.use((socket, next) => {
console.log(socket.connected); // prints "false"
next();
});
io.on("connection", (socket) => {
console.log(socket.connected); // prints "true"
});
```
Related: https://github.com/socketio/socket.io/issues/4129
2021-11-12 07:31:52 +01:00
Damien Arrachequesne
c0d8c5ab23
feat: add an implementation based on uWebSockets.js
...
Usage:
```js
const { App } = require("uWebSockets.js");
const { Server } = require("socket.io");
const app = new App();
const server = new Server();
server.attachApp(app);
app.listen(3000);
```
The Adapter prototype is updated so we can benefit from the publish
functionality of uWebSockets.js, so this will apply to all adapters
extending the default adapter.
Reference: https://github.com/uNetworking/uWebSockets.js
Related:
- https://github.com/socketio/socket.io/issues/3601
- https://github.com/socketio/engine.io/issues/578
2021-11-12 07:01:55 +01:00
Nikita Kolmogorov
fe8730ca0f
feat: add type information to socket.data ( #4159 )
...
Usage:
```js
interface SocketData {
name: string;
age: number;
}
const io = new Server<ClientToServerEvents, ServerToClientEvents, InterServerEvents, SocketData>();
io.on("connection", (socket) => {
socket.data.name = "john";
socket.data.age = 42;
});
```
2021-11-08 15:21:48 +01:00
Damien Arrachequesne
ed8483da4d
chore(release): 4.3.2
...
Diff: https://github.com/socketio/socket.io/compare/4.3.1...4.3.2
4.3.2
2021-11-08 06:39:20 +01:00
Sebastiaan Marynissen
9d86397243
fix: fix race condition in dynamic namespaces ( #4137 )
...
Using an async operation with `io.use()` could lead to the creation of
several instances of a same namespace, each of them overriding the
previous one.
Example:
```js
io.use(async (nsp, auth, next) => {
await anOperationThatTakesSomeTime();
next();
});
```
Related: https://github.com/socketio/socket.io/pull/4136
2021-10-24 07:46:29 +02:00
Naseem
44e20ba5bf
refactor: add event type for use() ( #4138 )
2021-10-24 07:19:43 +02:00
Damien Arrachequesne
ccc5ec39a8
chore(release): 4.3.1
...
Diff: https://github.com/socketio/socket.io/compare/4.3.0...4.3.1
4.3.1
2021-10-17 00:02:16 +02:00
Josh Field
0ef2a4d02c
fix: fix server attachment ( #4127 )
...
The check excluded an HTTPS server from being properly attached.
Related: https://github.com/socketio/socket.io/issues/4124
2021-10-16 23:58:55 +02:00
Damien Arrachequesne
95810aa62d
chore(release): 4.3.0
...
Diff: https://github.com/socketio/socket.io/compare/4.2.0...4.3.0
4.3.0
2021-10-14 14:59:13 +02:00
Damien Arrachequesne
60edecb3bd
feat: serve ESM bundle
...
Related:
- 0661564dc2
- https://github.com/socketio/socket.io-client/issues/1198
2021-10-13 18:17:12 +02:00
Damien Arrachequesne
eb5fdbd03e
chore: bump engine.io to version 6.0.0
...
Release notes: https://github.com/socketio/engine.io/releases/tag/6.0.0
Diff: https://github.com/socketio/engine.io/compare/5.2.0...6.0.0
2021-10-12 00:05:10 +02:00
roh-kan
4974e9077c
docs: update .NET client library link ( #4115 )
2021-10-08 14:18:03 +02:00
douira
033c5d399a
fix(typings): add name field to cookie option ( #4099 )
...
Reference: 18a6eb89fb/lib/server.js (L355)
2021-09-20 09:13:38 +02:00
Damien Arrachequesne
7a74b66872
test: remove hardcoded ports
...
Related: https://github.com/socketio/socket.io/issues/3447
2021-09-09 08:57:11 +02:00
Damien Arrachequesne
dc81fcf461
fix: send volatile packets with binary attachments
...
The binary attachments of volatile packets were discarded (only the
header packet was sent) due to a bug introduced by [1].
Related: https://github.com/socketio/socket.io/issues/3919
[1]: dc381b72c6
2021-09-09 08:55:51 +02:00
Damien Arrachequesne
c100b7b61c
chore(release): 4.2.0
...
Diff: https://github.com/socketio/socket.io/compare/4.1.3...4.2.0
4.2.0
2021-08-30 09:21:00 +02:00
Damien Arrachequesne
f03eeca39a
chore: bump dependencies
2021-08-30 08:27:46 +02:00
Damien Arrachequesne
d8cc8aef7e
docs: update the link of the Repl.it badge
...
The link will now point towards a sample project, instead of the root
repository.
Related: https://github.com/socketio/socket.io/issues/3934
2021-08-30 08:03:55 +02:00
Damien Arrachequesne
ccfd8caba6
fix(typings): allow async listener in typed events
...
So that:
```ts
socket.on("my-event", async () => {
// ...
});
```
is valid under the @typescript-eslint/no-misused-promises rule.
Related: https://github.com/socketio/socket.io-client/issues/1486
2021-08-30 08:01:29 +02:00
Tim Düsterhus
24fee27ba3
feat: ignore the query string when serving client JavaScript ( #4024 )
...
Related: https://github.com/socketio/socket.io/issues/4023
2021-08-30 07:59:47 +02:00
brownman
310f8557a7
docs(examples): add missing module ( #4018 )
...
Fixes the following error:
> test/todo-management/todo.tests.ts:275:3 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
Co-authored-by: brownman <brownman@users.noreply.github.com >
2021-07-15 21:48:20 +02:00
Damien Arrachequesne
dbd2a07cda
chore(release): 4.1.3
...
Diff: https://github.com/socketio/socket.io/compare/4.1.2...4.1.3
4.1.3
2021-07-10 12:13:15 +02:00
Damien Arrachequesne
94e27cd072
fix: fix io.except() method
...
Previously, calling `io.except("theroom").emit(...)` did not exclude
the sockets in the given room.
This method was forgotten in [1].
[1]: ac9e8ca6c7
2021-07-10 11:48:46 +02:00
Damien Arrachequesne
a4dffc6527
fix: remove x-sourcemap header
...
This header is useless, as the client bundle already contains a
sourceMappingURL field.
Besides, Firefox prints the following warning:
> <url> is being assigned a //# sourceMappingURL, but already has one
Related: https://github.com/socketio/socket.io/issues/3958
2021-07-04 00:51:41 +02:00
Damien Arrachequesne
7c44893d78
chore: bump dependencies
2021-07-04 00:37:35 +02:00
Daniele TDC
b833f918c8
ci: update to node 16 ( #3990 )
...
See also: https://github.com/nodejs/Release#release-schedule
2021-06-28 09:09:44 +02:00
Daniele TDC
24d8d1f67f
ci: update setup-node step ( #3986 )
2021-06-24 14:53:46 +02:00
Damien Arrachequesne
6f2a50b932
docs(examples): update example to webpack 5
2021-06-15 22:35:06 +02:00
Damien Arrachequesne
1633150b2b
chore(release): 4.1.2
...
Diff: https://github.com/socketio/socket.io/compare/4.1.1...4.1.2
4.1.2
2021-05-17 23:17:31 +02:00
Damien Arrachequesne
0cb6ac95b4
fix(typings): ensure compatibility with TypeScript 3.x
...
Labeled tuple elements were added in TypeScript 4.0.
Reference: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#labeled-tuple-elements
Related: https://github.com/socketio/socket.io/issues/3916
2021-05-17 23:15:22 +02:00
Damien Arrachequesne
a2cf2486c3
fix: ensure compatibility with previous versions of the adapter
...
Using `socket.io@4.1.0` with `socket.io-adapter@2.2.0` would lead to
the following error:
> Uncaught Error: unknown packet type NaN
Because the packet would be encoded twice, resulting in "undefined".
See also:
- 5579d40c24
- dc381b72c6
Related:
- https://github.com/socketio/socket.io/issues/3922
- https://github.com/socketio/socket.io/issues/3927
2021-05-17 23:14:36 +02:00
Damien Arrachequesne
995f38f4cc
chore(release): 4.1.1
...
Diff: https://github.com/socketio/socket.io/compare/4.1.0...4.1.1
4.1.1
2021-05-12 00:04:52 +02:00
Damien Arrachequesne
891b1870e9
fix(typings): properly type the adapter attribute
...
Related: https://github.com/socketio/socket.io/issues/3796
2021-05-11 23:59:44 +02:00
Damien Arrachequesne
b84ed1e41c
fix(typings): properly type server-side events
...
See also: 93cce05fb3
2021-05-11 23:59:18 +02:00
Damien Arrachequesne
fb6b0efec9
chore(release): 4.1.0
...
Diff: https://github.com/socketio/socket.io/compare/4.0.2...4.1.0
4.1.0
2021-05-11 09:27:52 +02:00
Damien Arrachequesne
95d9e4a42f
test: fix randomly failing test
2021-05-11 00:06:03 +02:00
Damien Arrachequesne
499c89250d
feat: notify upon namespace creation
...
A "new_namespace" event will be emitted when a new namespace is created:
```js
io.on("new_namespace", (namespace) => {
// ...
});
```
This could be used for example for registering the same middleware for
each namespace.
See https://github.com/socketio/socket.io/issues/3851
2021-05-11 00:09:18 +02:00
Damien Arrachequesne
93cce05fb3
feat: add support for inter-server communication
...
Syntax:
```js
// server A
io.serverSideEmit("hello", "world");
// server B
io.on("hello", (arg) => {
console.log(arg); // prints "world"
});
```
With acknowledgements:
```js
// server A
io.serverSideEmit("hello", "world", (err, responses) => {
console.log(responses); // prints ["hi"]
});
// server B
io.on("hello", (arg, callback) => {
callback("hi");
});
```
This feature replaces the customHook/customRequest API from the Redis
adapter: https://github.com/socketio/socket.io-redis/issues/370
2021-05-11 00:07:20 +02:00
Damien Arrachequesne
dc381b72c6
perf: add support for the "wsPreEncoded" writing option
...
Packets that are sent to multiple clients will now be pre-encoded for
the WebSocket transport (which means simply prepending "4" - which is
the "message" packet type in Engine.IO).
Note: buffers are not pre-encoded, since they are sent without
modification over the WebSocket connection
See also: 7706b123df
engine.io diff: https://github.com/socketio/engine.io/compare/5.0.0...5.1.0
2021-05-11 00:06:03 +02:00
Damien Arrachequesne
9fff03487c
chore(release): 4.0.2
...
Diff: https://github.com/socketio/socket.io/compare/4.0.1...4.0.2
4.0.2
2021-05-06 14:38:26 +02:00
Damien Arrachequesne
b81ce4c9d0
fix(typings): make "engine" attribute public
2021-05-06 14:36:25 +02:00
Damien Arrachequesne
d65b6ee84c
fix: properly export the Socket class
...
Before this change, `require("socket.io").Socket` would return
"undefined".
Note: having access to the Socket class allows users to modify its
prototype.
Related: https://github.com/socketio/socket.io/issues/3726
2021-05-06 14:36:12 +02:00
Damien Arrachequesne
3665aada47
docs(examples): basic CRUD application
...
See also: https://socket.io/get-started/basic-crud-application/
2021-04-23 00:08:18 +02:00
Damien Arrachequesne
1faa7e3aea
chore(release): 4.0.1
...
Diff: https://github.com/socketio/socket.io/compare/4.0.0...4.0.1
4.0.1
2021-04-01 01:25:56 +02:00
Maxime Kjaer
a11152f42b
fix(typings): add fallback to untyped event listener ( #3834 )
...
Related: https://github.com/socketio/socket.io/issues/3833
2021-03-31 11:37:37 +02:00