Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: socketio/socket.io
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 225ade062a13030164f89356b0a41f28203c3458
Choose a base ref
...
head repository: socketio/socket.io
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8be95b3bd323f83b9bc5d7b0292abc2dbea9ce56
Choose a head ref
Loading
Showing with 20,603 additions and 39,155 deletions.
  1. +1 −1 .github/ISSUE_TEMPLATE/bug_report.md
  2. +5 −2 .github/workflows/ci.yml
  3. +212 −0 CHANGELOG.md
  4. +10 −4 Readme.md
  5. +7 −0 client-dist/socket.io.esm.min.js
  6. +1 −0 client-dist/socket.io.esm.min.js.map
  7. +3,762 −5,194 client-dist/socket.io.js
  8. +1 −1 client-dist/socket.io.js.map
  9. +4 −4 client-dist/socket.io.min.js
  10. +1 −1 client-dist/socket.io.min.js.map
  11. +4 −4 client-dist/socket.io.msgpack.min.js
  12. +1 −1 client-dist/socket.io.msgpack.min.js.map
  13. +1 −0 examples/.gitignore
  14. +0 −13,694 examples/angular-todomvc/package-lock.json
  15. +2 −2 examples/angular-todomvc/package.json
  16. +2 −2 examples/angular-todomvc/server.ts
  17. +26 −0 examples/basic-crud-application/README.md
  18. +17 −0 examples/basic-crud-application/angular-client/.browserslistrc
  19. +16 −0 examples/basic-crud-application/angular-client/.editorconfig
  20. +46 −0 examples/basic-crud-application/angular-client/.gitignore
  21. +31 −0 examples/basic-crud-application/angular-client/README.md
  22. +128 −0 examples/basic-crud-application/angular-client/angular.json
  23. BIN examples/basic-crud-application/angular-client/assets/demo.gif
  24. +37 −0 examples/basic-crud-application/angular-client/e2e/protractor.conf.js
  25. +23 −0 examples/basic-crud-application/angular-client/e2e/src/app.e2e-spec.ts
  26. +11 −0 examples/basic-crud-application/angular-client/e2e/src/app.po.ts
  27. +13 −0 examples/basic-crud-application/angular-client/e2e/tsconfig.json
  28. +44 −0 examples/basic-crud-application/angular-client/karma.conf.js
  29. +46 −0 examples/basic-crud-application/angular-client/package.json
  30. 0 examples/basic-crud-application/angular-client/src/app/app.component.css
  31. +23 −0 examples/basic-crud-application/angular-client/src/app/app.component.html
  32. +31 −0 examples/basic-crud-application/angular-client/src/app/app.component.spec.ts
  33. +59 −0 examples/basic-crud-application/angular-client/src/app/app.component.ts
  34. +19 −0 examples/basic-crud-application/angular-client/src/app/app.module.ts
  35. +140 −0 examples/basic-crud-application/angular-client/src/app/store.ts
  36. 0 examples/basic-crud-application/angular-client/src/assets/.gitkeep
  37. +4 −0 examples/basic-crud-application/angular-client/src/environments/environment.prod.ts
  38. +17 −0 examples/basic-crud-application/angular-client/src/environments/environment.ts
  39. BIN examples/basic-crud-application/angular-client/src/favicon.ico
  40. +13 −0 examples/basic-crud-application/angular-client/src/index.html
  41. +12 −0 examples/basic-crud-application/angular-client/src/main.ts
  42. +63 −0 examples/basic-crud-application/angular-client/src/polyfills.ts
  43. +381 −0 examples/basic-crud-application/angular-client/src/styles.css
  44. +25 −0 examples/basic-crud-application/angular-client/src/test.ts
  45. +15 −0 examples/basic-crud-application/angular-client/tsconfig.app.json
  46. +29 −0 examples/basic-crud-application/angular-client/tsconfig.json
  47. +18 −0 examples/basic-crud-application/angular-client/tsconfig.spec.json
  48. +152 −0 examples/basic-crud-application/angular-client/tslint.json
  49. +16 −0 examples/basic-crud-application/server-postgres-cluster/README.md
  50. +9 −0 examples/basic-crud-application/server-postgres-cluster/docker-compose.yml
  51. +26 −0 examples/basic-crud-application/server-postgres-cluster/lib/app.js
  52. +28 −0 examples/basic-crud-application/server-postgres-cluster/lib/cluster.js
  53. +51 −0 examples/basic-crud-application/server-postgres-cluster/lib/index.js
  54. +140 −0 examples/basic-crud-application/server-postgres-cluster/lib/todo-management/todo.handlers.js
  55. +74 −0 examples/basic-crud-application/server-postgres-cluster/lib/todo-management/todo.repository.js
  56. +22 −0 examples/basic-crud-application/server-postgres-cluster/lib/util.js
  57. +30 −0 examples/basic-crud-application/server-postgres-cluster/package.json
  58. +35 −0 examples/basic-crud-application/server/lib/app.ts
  59. +37 −0 examples/basic-crud-application/server/lib/events.ts
  60. +19 −0 examples/basic-crud-application/server/lib/index.ts
  61. +159 −0 examples/basic-crud-application/server/lib/todo-management/todo.handlers.ts
  62. +49 −0 examples/basic-crud-application/server/lib/todo-management/todo.repository.ts
  63. +24 −0 examples/basic-crud-application/server/lib/util.ts
  64. +37 −0 examples/basic-crud-application/server/package.json
  65. +309 −0 examples/basic-crud-application/server/test/todo-management/todo.tests.ts
  66. +11 −0 examples/basic-crud-application/server/tsconfig.json
  67. +1 −1 examples/chat/README.md
  68. +0 −499 examples/chat/package-lock.json
  69. +1 −1 examples/chat/package.json
  70. +3 −3 examples/chat/public/main.js
  71. +1 −1 examples/cluster-haproxy/server/package.json
  72. +1 −1 examples/cluster-httpd/server/package.json
  73. +1 −1 examples/cluster-nginx/client/package.json
  74. +3 −1 examples/cluster-nginx/docker-compose.yml
  75. 0 examples/cluster-nginx/{nginx → }/nginx.conf
  76. +0 −3 examples/cluster-nginx/nginx/Dockerfile
  77. +21 −18 examples/cluster-nginx/server/index.js
  78. +3 −2 examples/cluster-nginx/server/package.json
  79. +1 −1 examples/cluster-traefik/server/package.json
  80. +2 −2 examples/create-react-app-example/package.json
  81. +5 −1 examples/create-react-app-example/server.js
  82. +14 −1 examples/create-react-app-example/src/App.js
  83. +2,010 −1,807 examples/create-react-app-example/yarn.lock
  84. +4 −4 examples/custom-parsers/package.json
  85. +1 −0 examples/custom-parsers/public/.gitignore
  86. +3 −3 examples/custom-parsers/src/custom-parser.js
  87. +11 −4 examples/custom-parsers/src/server.js
  88. +0 −217 examples/es-modules/package-lock.json
  89. +2 −2 examples/es-modules/package.json
  90. +16 −0 examples/express-session-example/README.md
  91. BIN examples/express-session-example/assets/demo.gif
  92. +57 −0 examples/express-session-example/index.html
  93. +91 −0 examples/express-session-example/index.js
  94. +15 −0 examples/express-session-example/package.json
  95. +2 −2 examples/passport-example/index.js
  96. +0 −783 examples/passport-example/package-lock.json
  97. +1 −1 examples/passport-example/package.json
  98. +1 −1 examples/private-messaging/package.json
  99. +1 −1 examples/private-messaging/server/package.json
  100. +0 −6,654 examples/react-native/package-lock.json
  101. +2 −2 examples/react-native/package.json
  102. +1 −0 examples/rollup-server-bundle/.gitignore
  103. +3 −0 examples/rollup-server-bundle/index.js
  104. +19 −0 examples/rollup-server-bundle/package.json
  105. +12 −0 examples/rollup-server-bundle/rollup.config.js
  106. +5 −1 examples/tweet-stream/index.js
  107. +0 −705 examples/tweet-stream/package-lock.json
  108. +1 −1 examples/tweet-stream/package.json
  109. +0 −295 examples/typescript/package-lock.json
  110. +2 −2 examples/typescript/package.json
  111. +2 −2 examples/typescript/server.ts
  112. +20 −0 examples/webpack-build-server/index.js
  113. +0 −16 examples/webpack-build-server/lib/index.js
  114. +0 −4,137 examples/webpack-build-server/package-lock.json
  115. +6 −4 examples/webpack-build-server/package.json
  116. +0 −9 examples/webpack-build-server/support/webpack.config.js
  117. +19 −0 examples/webpack-build-server/webpack.config.js
  118. +1 −10 examples/webpack-build/README.md
  119. +2 −3 examples/webpack-build/index.html
  120. +15 −0 examples/webpack-build/index.js
  121. +0 −12 examples/webpack-build/lib/index.js
  122. +5 −10 examples/webpack-build/package.json
  123. +0 −2 examples/webpack-build/support/noop.js
  124. +0 −8 examples/webpack-build/support/webpack.config.js
  125. +0 −33 examples/webpack-build/support/webpack.config.json-parser.js
  126. +0 −31 examples/webpack-build/support/webpack.config.slim.js
  127. +7 −0 examples/webpack-build/webpack.config.js
  128. +0 −499 examples/whiteboard/package-lock.json
  129. +1 −1 examples/whiteboard/package.json
  130. +404 −0 lib/broadcast-operator.ts
  131. +93 −47 lib/client.ts
  132. +292 −158 lib/index.ts
  133. +245 −97 lib/namespace.ts
  134. +45 −13 lib/parent-namespace.ts
  135. +305 −81 lib/socket.ts
  136. +180 −0 lib/typed-events.ts
  137. +164 −0 lib/uws.ts
  138. +6,222 −1,473 package-lock.json
  139. +23 −21 package.json
  140. +181 −0 test/close.ts
  141. +1 −1 test/fixtures/server-close.ts
  142. +87 −0 test/handshake.ts
  143. +23 −0 test/index.ts
  144. +501 −0 test/messaging-many.ts
  145. +210 −0 test/middleware.ts
  146. +575 −0 test/namespaces.ts
  147. +170 −0 test/server-attachment.ts
  148. +60 −0 test/socket-middleware.ts
  149. +57 −0 test/socket-timeout.ts
  150. +300 −0 test/socket.io.test-d.ts
  151. +0 −2,555 test/socket.io.ts
  152. +1,043 −0 test/socket.ts
  153. +59 −1 test/support/util.ts
  154. +164 −0 test/utility-methods.ts
  155. +211 −0 test/uws.ts
  156. +64 −0 test/v2-compatibility.ts
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'bug'
labels: 'to triage'
assignees: ''

---
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -6,18 +6,21 @@ on:
schedule:
- cron: '0 0 * * 0'

permissions:
contents: read

jobs:
test-node:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
node-version: [12, 14, 16]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
212 changes: 212 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,215 @@
## [4.5.2](https://github.com/socketio/socket.io/compare/4.5.1...4.5.2) (2022-09-02)


### Bug Fixes

* prevent the socket from joining a room after disconnection ([18f3fda](https://github.com/socketio/socket.io/commit/18f3fdab12947a9fee3e9c37cfc1da97027d1473))
* **uws:** prevent the server from crashing after upgrade ([ba497ee](https://github.com/socketio/socket.io/commit/ba497ee3eb52c4abf1464380d015d8c788714364))



## [4.5.1](https://github.com/socketio/socket.io/compare/4.5.0...4.5.1) (2022-05-17)


### Bug Fixes

* forward the local flag to the adapter when using fetchSockets() ([30430f0](https://github.com/socketio/socket.io/commit/30430f0985f8e7c49394543d4c84913b6a15df60))
* **typings:** add HTTPS server to accepted types ([#4351](https://github.com/socketio/socket.io/issues/4351)) ([9b43c91](https://github.com/socketio/socket.io/commit/9b43c9167cff817c60fa29dbda2ef7cd938aff51))



# [4.5.0](https://github.com/socketio/socket.io/compare/4.4.1...4.5.0) (2022-04-23)


### Bug Fixes

* **typings:** ensure compatibility with TypeScript 3.x ([#4259](https://github.com/socketio/socket.io/issues/4259)) ([02c87a8](https://github.com/socketio/socket.io/commit/02c87a85614e217b8e7b93753f315790ae9d99f6))


### Features

* add support for catch-all listeners for outgoing packets ([531104d](https://github.com/socketio/socket.io/commit/531104d332690138b7aab84d5583d6204132c8b4))

This is similar to `onAny()`, but for outgoing packets.

Syntax:

```js
socket.onAnyOutgoing((event, ...args) => {
console.log(event);
});
```

* broadcast and expect multiple acks ([8b20457](https://github.com/socketio/socket.io/commit/8b204570a94979bbec307f23ca078f30f5cf07b0))

Syntax:

```js
io.timeout(1000).emit("some-event", (err, responses) => {
// ...
});
```

* add the "maxPayload" field in the handshake details ([088dcb4](https://github.com/socketio/engine.io/commit/088dcb4dff60df39785df13d0a33d3ceaa1dff38))

So that clients in HTTP long-polling can decide how many packets they have to send to stay under the maxHttpBufferSize
value.

This is a backward compatible change which should not mandate a new major revision of the protocol (we stay in v4), as
we only add a field in the JSON-encoded handshake data:

```
0{"sid":"lv_VI97HAXpY6yYWAAAC","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":5000,"maxPayload":1000000}
```



## [4.4.1](https://github.com/socketio/socket.io/compare/4.4.0...4.4.1) (2022-01-06)


### Bug Fixes

* **types:** make `RemoteSocket.data` type safe ([#4234](https://github.com/socketio/socket.io/issues/4234)) ([770ee59](https://github.com/socketio/socket.io/commit/770ee5949fb47c2556876c622f06c862573657d6))
* **types:** pass `SocketData` type to custom namespaces ([#4233](https://github.com/socketio/socket.io/issues/4233)) ([f2b8de7](https://github.com/socketio/socket.io/commit/f2b8de71919e1b4d3e57f15a459972c1d1064787))



# [4.4.0](https://github.com/socketio/socket.io/compare/4.3.2...4.4.0) (2021-11-18)


### Bug Fixes

* only set 'connected' to true after middleware execution ([02b0f73](https://github.com/socketio/socket.io/commit/02b0f73e2c64b09c72c5fbf7dc5f059557bdbe50))


### Features

* add an implementation based on uWebSockets.js ([c0d8c5a](https://github.com/socketio/socket.io/commit/c0d8c5ab234d0d2bef0d0dec472973cc9662f647))
* add timeout feature ([f0ed42f](https://github.com/socketio/socket.io/commit/f0ed42f18cabef20ad976aeec37077b6bf3837a5))
* add type information to `socket.data` ([#4159](https://github.com/socketio/socket.io/issues/4159)) ([fe8730c](https://github.com/socketio/socket.io/commit/fe8730ca0f15bc92d5de81cf934c89c76d6af329))



## [4.3.2](https://github.com/socketio/socket.io/compare/4.3.1...4.3.2) (2021-11-08)


### Bug Fixes

* fix race condition in dynamic namespaces ([#4137](https://github.com/socketio/socket.io/issues/4137)) ([9d86397](https://github.com/socketio/socket.io/commit/9d86397243bcbb5775a29d96e5ef03e17148a8e7))


## [4.3.1](https://github.com/socketio/socket.io/compare/4.3.0...4.3.1) (2021-10-16)


### Bug Fixes

* fix server attachment ([#4127](https://github.com/socketio/socket.io/issues/4127)) ([0ef2a4d](https://github.com/socketio/socket.io/commit/0ef2a4d02c9350aff163df9cb61aece89c4dac0f))


# [4.3.0](https://github.com/socketio/socket.io/compare/4.2.0...4.3.0) (2021-10-14)


### Bug Fixes

* **typings:** add name field to cookie option ([#4099](https://github.com/socketio/socket.io/issues/4099)) ([033c5d3](https://github.com/socketio/socket.io/commit/033c5d399a2b985afad32c1e4b0c16d764e248cd))
* send volatile packets with binary attachments ([dc81fcf](https://github.com/socketio/socket.io/commit/dc81fcf461cfdbb5b34b1a5a96b84373754047d5))


### Features

* serve ESM bundle ([60edecb](https://github.com/socketio/socket.io/commit/60edecb3bd33801803cdcba0aefbafa381a2abb3))


# [4.2.0](https://github.com/socketio/socket.io/compare/4.1.3...4.2.0) (2021-08-30)


### Bug Fixes

* **typings:** allow async listener in typed events ([ccfd8ca](https://github.com/socketio/socket.io/commit/ccfd8caba6d38b7ba6c5114bd8179346ed07671c))


### Features

* ignore the query string when serving client JavaScript ([#4024](https://github.com/socketio/socket.io/issues/4024)) ([24fee27](https://github.com/socketio/socket.io/commit/24fee27ba36485308f8e995879c10931532c814e))


## [4.1.3](https://github.com/socketio/socket.io/compare/4.1.2...4.1.3) (2021-07-10)


### Bug Fixes

* fix io.except() method ([94e27cd](https://github.com/socketio/socket.io/commit/94e27cd072c8a4eeb9636f6ffbb7a21d382f36b0))
* remove x-sourcemap header ([a4dffc6](https://github.com/socketio/socket.io/commit/a4dffc6527f412d51a786ae5bf2e9080fe1ca63c))


## [4.1.2](https://github.com/socketio/socket.io/compare/4.1.1...4.1.2) (2021-05-17)


### Bug Fixes

* **typings:** ensure compatibility with TypeScript 3.x ([0cb6ac9](https://github.com/socketio/socket.io/commit/0cb6ac95b49a27483b6f1b6402fa54b35f82e36f))
* ensure compatibility with previous versions of the adapter ([a2cf248](https://github.com/socketio/socket.io/commit/a2cf2486c366cb62293101c10520c57f6984a3fc))


## [4.1.1](https://github.com/socketio/socket.io/compare/4.1.0...4.1.1) (2021-05-11)


### Bug Fixes

* **typings:** properly type server-side events ([b84ed1e](https://github.com/socketio/socket.io/commit/b84ed1e41c9053792caf58974c5de9395bfd509f))
* **typings:** properly type the adapter attribute ([891b187](https://github.com/socketio/socket.io/commit/891b1870e92d1ec38910f03bb839817e2d6be65a))


# [4.1.0](https://github.com/socketio/socket.io/compare/4.0.2...4.1.0) (2021-05-11)


### Features

* add support for inter-server communication ([93cce05](https://github.com/socketio/socket.io/commit/93cce05fb3faf91f21fa71212275c776aa161107))
* notify upon namespace creation ([499c892](https://github.com/socketio/socket.io/commit/499c89250d2db1ab7725ab2b74840e188c267c46))
* add a "connection_error" event ([7096e98](https://github.com/socketio/engine.io/commit/7096e98a02295a62c8ea2aa56461d4875887092d), from `engine.io`)
* add the "initial_headers" and "headers" events ([2527543](https://github.com/socketio/engine.io/commit/252754353a0e88eb036ebb3082e9d6a9a5f497db), from `engine.io`)


### Performance Improvements

* add support for the "wsPreEncoded" writing option ([dc381b7](https://github.com/socketio/socket.io/commit/dc381b72c6b2f8172001dedd84116122e4cc95b3))


## [4.0.2](https://github.com/socketio/socket.io/compare/4.0.1...4.0.2) (2021-05-06)


### Bug Fixes

* **typings:** make "engine" attribute public ([b81ce4c](https://github.com/socketio/socket.io/commit/b81ce4c9d0b00666361498e2ba5e0d007d5860b8))
* properly export the Socket class ([d65b6ee](https://github.com/socketio/socket.io/commit/d65b6ee84c8e91deb61c3c1385eb19afa196a909))


## [4.0.1](https://github.com/socketio/socket.io/compare/4.0.0...4.0.1) (2021-03-31)


### Bug Fixes

* **typings:** add fallback to untyped event listener ([#3834](https://github.com/socketio/socket.io/issues/3834)) ([a11152f](https://github.com/socketio/socket.io/commit/a11152f42b281df83409313962f60f230239c79e))
* **typings:** update return type from emit ([#3843](https://github.com/socketio/socket.io/issues/3843)) ([1a72ae4](https://github.com/socketio/socket.io/commit/1a72ae4fe27a14cf60916f991a2c94da91d9e54a))


# [4.0.0](https://github.com/socketio/socket.io/compare/3.1.2...4.0.0) (2021-03-10)


### Bug Fixes

* make io.to(...) immutable ([ac9e8ca](https://github.com/socketio/socket.io/commit/ac9e8ca6c71e00d4af45ee03f590fe56f3951186))


### Features

* add some utility methods ([b25495c](https://github.com/socketio/socket.io/commit/b25495c069031674da08e19aed68922c7c7a0e28))
* add support for typed events ([#3822](https://github.com/socketio/socket.io/issues/3822)) ([0107510](https://github.com/socketio/socket.io/commit/0107510ba8a0f148c78029d8be8919b350feb633))
* allow to exclude specific rooms when broadcasting ([#3789](https://github.com/socketio/socket.io/issues/3789)) ([7de2e87](https://github.com/socketio/socket.io/commit/7de2e87e888d849eb2dfc5e362af4c9e86044701))
* allow to pass an array to io.to(...) ([085d1de](https://github.com/socketio/socket.io/commit/085d1de9df909651de8b313cc6f9f253374b702e))


## [3.1.2](https://github.com/socketio/socket.io/compare/3.1.1...3.1.2) (2021-02-26)


14 changes: 10 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# socket.io
[![Run on Repl.it](https://repl.it/badge/github/socketio/socket.io)](https://repl.it/github/socketio/socket.io)
[![Run on Repl.it](https://repl.it/badge/github/socketio/socket.io)](https://replit.com/@socketio/socketio-minimal-example)
[![Backers on Open Collective](https://opencollective.com/socketio/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/socketio/sponsors/badge.svg)](#sponsors)
[![Build Status](https://github.com/socketio/socket.io/workflows/CI/badge.svg)](https://github.com/socketio/socket.io/actions)
[![Dependency Status](https://david-dm.org/socketio/socket.io.svg)](https://david-dm.org/socketio/socket.io)
[![devDependency Status](https://david-dm.org/socketio/socket.io/dev-status.svg)](https://david-dm.org/socketio/socket.io#info=devDependencies)
[![NPM version](https://badge.fury.io/js/socket.io.svg)](https://www.npmjs.com/package/socket.io)
![Downloads](https://img.shields.io/npm/dm/socket.io.svg?style=flat)
[![](https://slackin-socketio.now.sh/badge.svg)](https://slackin-socketio.now.sh)
@@ -22,7 +20,7 @@ Some implementations in other languages are also available:
- [Swift](https://github.com/socketio/socket.io-client-swift)
- [Dart](https://github.com/rikulo/socket.io-client-dart)
- [Python](https://github.com/miguelgrinberg/python-socketio)
- [.Net](https://github.com/Quobject/SocketIoClientDotNet)
- [.NET](https://github.com/doghappy/socket.io-client-csharp)

Its main features are:

@@ -115,6 +113,14 @@ io.on('connection', client => { ... });
io.listen(3000);
```

### Module syntax

```js
import { Server } from "socket.io";
const io = new Server(server);
io.listen(3000);
```

### In conjunction with Express

Starting with **3.0**, express applications have become request handler
Loading