Damien Arrachequesne
d30630ba10
fix: add a noop handler for the error event
...
Backported from main: 15af22fc22
2024-06-19 10:46:29 +02:00
Damien Arrachequesne
f223178eb6
fix: prevent the socket from joining a room after disconnection
...
Calling `socket.join()` after disconnection would lead to a memory
leak, because the room was never removed from the memory:
```js
io.on("connection", (socket) => {
socket.disconnect();
socket.join("room1"); // leak
});
```
Related:
- https://github.com/socketio/socket.io/issues/4067
- https://github.com/socketio/socket.io/issues/4380
Backported from 18f3fdab12
2022-06-26 08:54:51 +02:00
Damien Arrachequesne
226cc16165
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
Backported from 02b0f73e2c
2022-06-26 08:46:28 +02:00
Damien Arrachequesne
22d4bdf00d
fix: ignore packet received after disconnection
...
Related: https://github.com/socketio/socket.io/issues/3095
Backported from 494c64e44f
2022-06-26 08:35:42 +02:00
Sebastiaan Marynissen
d33a619905
fix: properly overwrite the query sent in the handshake
...
The `query` option of the Manager had the priority over the one of the
Socket instance, which meant updating the Socket#query object on the
client-side was not reflected in the Socket#handshake object on the
server-side.
Please note that the behavior of the `query` option is still a bit
weird in Socket.IO v2, as it only applies to non-default namespace.
This is fixed in v3:
- https://socket.io/docs/v3/migrating-from-2-x-to-3-0/#Add-a-clear-distinction-between-the-Manager-query-option-and-the-Socket-query-option
- https://socket.io/docs/v3/middlewares/#Sending-credentials
Fixes https://github.com/socketio/socket.io/issues/3495
2021-01-04 11:34:24 +01:00
Sleiman Sleiman
1decae341c
[feat] Add local flag to the socket object ( #3219 )
...
To match the behaviour on the namespace (see #2628 ).
2018-04-27 13:03:25 +02:00
Damien Arrachequesne
f48a06c040
[feat] Add a 'binary' flag ( #3185 )
...
So that the call to the `has-binary` method can be skipped. Usage:
```
// with binary data
socket.binary(true).emit("binary", obj);
// without binary data
socket.binary(false).emit("string", obj);
// call to hasBin
socket.emit("guess", obj);
```
2018-02-28 23:00:16 +01:00
Damien Arrachequesne
dd69abbeee
[fix] Reset rooms object before broadcasting from namespace ( #3039 )
2017-08-26 07:36:26 +02:00
Damien Arrachequesne
1f0e64a6da
[fix] Do not throw when receiving an unhandled error packet ( #3038 )
2017-08-26 07:35:57 +02:00
Damien Arrachequesne
db0c69969e
[fix] Reset rooms object before broadcasting ( #2970 )
...
It seems packets could be delivered to wrong room in some case, if the
_rooms array was not reset before the next emit.
2017-06-12 14:01:35 +02:00
Damien Arrachequesne
2b216902e1
[fix] Fix timing issues with middleware ( #2948 )
...
Using a middleware could previously lead to a connecting client
receiving a connect event from the server before the server triggers
its own connect event.
2017-05-22 13:01:59 +02:00
Damien Arrachequesne
87b06ad362
[feat] Move binary detection to the parser ( #2923 )
2017-04-25 00:38:07 +02:00
Damien Arrachequesne
01a4623613
[feat] Allow to join several rooms at once ( #2879 )
2017-02-26 09:15:32 +01:00
Damien Arrachequesne
54ff591b07
[feature] Merge Engine.IO and Socket.IO handshake packets ( #2833 )
2017-02-01 15:28:14 +01:00
Tom Atkinson
e24434a0a0
[perf] Reset properties instead of deleting them ( #2826 )
...
Deleting properties is a v8 'optimization killer'
2017-01-16 08:23:22 +01:00
Gatsbill
c46d4481bd
[perf] micro-optimisations ( #2793 )
2016-12-30 16:18:09 +01:00
Serhii Sol
1e31769062
[fix] Fixes socket.use error packet ( #2772 )
...
* fix(socket): Fixes socket.use error packet which drops nodejs due to nuances of Nodejs' EventEmitter
* fix(socket): Fixes missing error event on socket
* fix(socket): test fix, should listen for clientSocket instead of server socket
* minor update
2016-12-01 02:25:13 +01:00
Jérémy Lal
d48f848bb4
[docs] Comment connected socket availability for adapters ( #2081 )
2016-11-23 15:00:07 +01:00
Luca Tabone
ff2c15de68
[perf] Minor code optimizations ( #2219 )
2016-11-18 02:03:06 +01:00
Julian Grinblat
4c5dbd8824
[fix] Don't drop query variables on handshake ( #2745 )
...
Parameters passed during handshake, such as tokens, were being dropped.
2016-11-16 01:17:19 +01:00
Alex
5a123beea5
[feature] Add support for socket middleware ( #2306 )
2016-11-05 01:51:29 +01:00
Feram Bot
ccd3376627
[docs] Minor fixes ( #2526 )
2016-10-21 03:21:45 +02:00
Damien Arrachequesne
43d9a4b55d
[feature] Add a 'disconnecting' event to access to socket.rooms upon disconnection ( #2332 )
2016-10-06 23:23:26 +02:00
Guillermo Rauch
fb0253edea
Merge pull request #2422 from nus-fboa2016-si/queryStringFix
...
Fix for Issue #331 on socket.io-client
2016-04-11 08:44:59 -07:00
吳東曄 Wu, Dung-Ie
6d4128750b
stop append /# before id when no namespace
2016-04-02 01:55:53 +08:00
Zheng Weihan
c077357eff
add comments to code
2016-02-04 13:27:36 +08:00
Zheng Weihan
13af610f6d
add test for issue #331 on socket.io-client.
2016-01-31 15:44:39 +08:00
Zheng Weihan
1d84c55743
fix to issue #331 on socket.o-client.
...
Parses CONNECT packet for query string and replaces query in socket.handshake.
2016-01-28 14:40:05 +08:00
Naoyuki Kanezawa
2a91fd57c7
Merge pull request #2344 from denghongcai/patch-2
...
fix wrong jsdoc
2016-01-17 15:25:32 +09:00
Faizal Pribadi
abe2394a24
fix typo word :)
...
update docs source code
2015-12-20 16:16:42 +07:00
Hongcai Deng
7012ba6c64
fix wrong jsdoc
2015-12-14 15:31:42 +08:00
Damien Arrachequesne
1dfacc6647
Trigger callback even when joining an already joined room
2015-11-27 22:08:18 +01:00
Damien Arrachequesne
09f446eca0
Add hasOwnProperty checks
2015-11-23 15:12:21 +01:00
Damien Arrachequesne
b73d9bea4e
converted arrays to objects
2015-11-22 11:12:40 +01:00
Guillermo Rauch
2a4f7ae161
Merge pull request #2136 from nkzawa/patch-5
...
Don't set request property
2015-11-20 12:59:05 -08:00
Kevin Jose Martin
514aeb4fcd
Actually prevent double callbacks...
...
We declare `sent = false` and even check `if (sent)` is truthy, but we never set it to truthy, therefore it never really *prevents double callbacks*...
2015-07-06 11:36:00 -04:00
Naoyuki Kanezawa
4d36d6c01a
don't set request property
2015-05-30 03:34:05 +09:00
Guillermo Rauch
3f72dd3322
Merge pull request #2063 from kapouer/patch-1
...
Let adapter.add find connected socket
2015-04-10 21:38:41 -07:00
Jérémy Lal
425409945b
Let adapter.add find connected socket
...
When a socket connects, it joins its own room, resulting in a call to adapter.add.
The adapter in turn should be able to find the socket by id.
2015-03-24 14:54:52 +01:00
Naoyuki Kanezawa
81aea995ed
improve Socket#packet and Client#packet
2015-02-15 04:33:20 +09:00
Guillermo Rauch
5ce06d3088
socket: warn node_redis-style about missing error
2015-02-03 16:26:21 -08:00
Guillermo Rauch
1b01e16a6c
fix broken previous commit
2015-01-24 08:02:05 -08:00
Naoyuki Kanezawa
ac8e8598d7
support compression
2015-01-22 05:01:45 +09:00
Roman Shtylman
ca82c09bf2
fix leaving unknown rooms
...
close #1670
2015-01-10 14:58:50 -08:00
Guillermo Rauch
4e4bbf918e
fix protocol violations and improve error handling ( fixes #1880 )
2014-11-21 04:16:37 +01:00
Tony Kovanen
624e7cb14f
Fix splice arguments and socket.rooms value update in socket.leaveAll.
...
Hat tip @Marreck
2014-08-01 13:20:18 +02:00
Tony Kovanen
54726105cb
Fixed handshake object address property and made the test case more strict.
2014-07-19 04:43:03 +03:00
Naoyuki Kanezawa
a66bea5b33
add removeListener to blacklisted events
2014-06-08 20:34:50 +09:00
Kevin Roark
27dada65b9
distinction between ACK and BINARY_ACK
2014-05-30 18:42:23 -07:00
Tony Kovanen
10adcb089e
Added socket.handshake BC object
2014-05-24 17:02:47 +03:00