Compare commits

...

382 Commits
1.0.1 ... 1.5.1

Author SHA1 Message Date
Damien Arrachequesne
fdf64cc38f [chore] Release 1.5.1 (#2735) 2016-10-24 03:31:32 +02:00
Damien Arrachequesne
5badb6436e [chore] Bump socket.io-parser to 2.3.1 (#2734) 2016-10-24 03:23:03 +02:00
Damien Arrachequesne
c20e0b26c9 [chore] Bump engine.io to 1.7.2 (#2729) 2016-10-24 03:21:11 +02:00
bananaapple
5c10c5439b [test] Use client function to unify client in test script (#2731) 2016-10-24 02:35:01 +02:00
Damien Arrachequesne
8182ecc61c [chore] Add Github issue and PR templates (#2733) 2016-10-22 09:19:08 +02:00
Feram Bot
ccd3376627 [docs] Minor fixes (#2526) 2016-10-21 03:21:45 +02:00
Damien Arrachequesne
58a73d39e9 [chore] Bump socket.io-parser to 2.3.0 (#2730) 2016-10-21 03:18:49 +02:00
Tom Atkinson
e60bd5a4da [fix] Avoid swallowing exceptions thrown by user event handlers (#2682) 2016-10-21 03:16:36 +02:00
Paul Meinhardt
21dffa4b58 [docs] Link readme npm package badge to npm registry page (#2612) 2016-10-21 03:10:33 +02:00
Marcio Puga
94852e3d23 [docs] Fix typo (#2724) 2016-10-21 03:06:59 +02:00
davidlondono
b8c60506a6 [docs] Fix JSDoc of optional parameters (#2465)
Making proper optional Docs for socketIO
2016-10-21 03:02:59 +02:00
syuilo⭐️
ecc76f48bc [docs] Add link to LICENSE (#2221) 2016-10-21 03:00:38 +02:00
Damien Arrachequesne
c94058f9b0 [chore] release 1.5.0 (#2711) 2016-10-07 00:13:33 +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
Alejandro Oviedo
df916172dd [chore] Link build badge to master branch (#2549) 2016-10-06 23:12:15 +02:00
Damien Arrachequesne
271c625243 [chore] Restrict files included in npm package (#2709) 2016-10-06 23:11:33 +02:00
Damien Arrachequesne
628fe8f1b2 [chore] Point towards current master of socket.io-client (#2710) 2016-10-06 23:10:54 +02:00
Damien Arrachequesne
db62e1bf67 [chore] Remove unused zuul-ngrok dependency (#2708) 2016-10-06 23:10:33 +02:00
YasharF
ba4c7921ef [chore] Bump engine.io to 1.7.0 (#2707) 2016-10-06 10:03:55 +02:00
Damien Arrachequesne
30ea0b8d7d Merge pull request #2599 from boazsegev/patch-1
Documentation update to help new programmers
2016-08-05 21:07:30 +02:00
Bo
2d141aff7c Prevent mixup for new programmers
The documentation, inadvertently, causes confusion for newer programmers, hindering their learning curve and ability to learn `socket.io` faster.

This proposed change aims at preventing this confusion to allow new programmers easier access to resources, especially when searching the web for more information.

The name `socket` in the documentation refers to the API gateway, or abstraction layer, related to the `client` and other properties. However, in the rest of the programming world, `sockets` usually refer to Berklee sockets or the lower-level communication channel that is used to implement Protocols such as the Websocket Protocol and HTTP.

New programmers often search for more informations using the `sockets` keyword when they are grappling with learning the `socket.io` API.

A good example is the stack overflow site, where newer programmers incorrectly tag their questions `sockets` and in turn don't get a fast response to their questions.

By simply changing the name of the variable used to describe socket.io's "Socket" class instances from `socket` to `client`, this mixup should be mitigated considerably.
2016-06-26 14:32:37 -04:00
Guillermo Rauch
40763d3962 1.4.8 2016-06-23 19:24:38 -07:00
Guillermo Rauch
2a092bd2fb Release 1.4.8 2016-06-23 19:22:41 -07:00
Guillermo Rauch
4137eb5c43 package: bump engine.io 2016-06-23 19:12:28 -07:00
Guillermo Rauch
e3207005da 1.4.7 2016-06-23 17:31:33 -07:00
Guillermo Rauch
42aa77614e Release 1.4.7 2016-06-23 17:25:46 -07:00
Guillermo Rauch
1491a96c95 package: bump engine.io 2016-06-23 17:11:15 -07:00
Guillermo Rauch
dcca01f5a4 Release 1.4.6 2016-05-02 20:57:44 -07:00
Guillermo Rauch
3b58fa04d5 package: bump engine.io 2016-05-02 20:56:15 -07:00
Naoyuki Kanezawa
0c6d50d9c0 Merge pull request #2416 from nus-fboa2016-si/chatexample
updated express version to express 4
2016-04-12 03:58:08 +09:00
Naoyuki Kanezawa
881f16553c Merge pull request #2508 from tw0517tw/quote-exec
add quote to exec paths, prevent error when spaces in path
2016-04-12 03:57:43 +09:00
Guillermo Rauch
e5a8d4d2d9 Merge pull request #2520 from nkzawa/fix/ignore-dist
Ignore dist directory for now
2016-04-11 08:45:11 -07: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
tw0517tw
3c5f5a0864 use a bigger timeout for slower machine 2016-04-11 22:31:47 +08:00
tw0517tw
a23d26a617 add quote to exec paths, prevent error when spaces in path 2016-04-11 22:21:34 +08:00
Zhu Liang
910b5d77a6 fixed version notation 2016-04-11 22:19:49 +08:00
Naoyuki Kanezawa
438ad63cdf Merge pull request #2420 from revington/test-node-v5-stable
[Travis] Add Node 5.x (Stable) to the test matrix
2016-04-11 23:09:41 +09:00
Naoyuki Kanezawa
7e9a67d8ee Merge pull request #2415 from nus-fboa2016-si/documentation
Documentation
2016-04-11 23:05:33 +09:00
Naoyuki Kanezawa
0ae070885d Merge pull request #2477 from callahad/chat-layout-fix
Fix chat display in Firefox
2016-04-11 23:00:07 +09:00
Naoyuki Kanezawa
36d99d8d84 Merge pull request #2492 from westy92/master
Update package.json
2016-04-11 22:20:46 +09:00
nkzawa
0e63b0910e ignore dist for now 2016-04-11 22:11:19 +09:00
Guillermo Rauch
3c7350fa58 Merge pull request #2509 from tw0517tw/patch-1
stop prepend /# before id when no namespace
2016-04-10 11:24:42 -07:00
Guillermo Rauch
aadd5da655 Merge pull request #2496 from nus-fboa2016-si/compat-test
Added test for compat version transformed by babel
2016-04-02 18:31:30 -07:00
吳東曄 Wu, Dung-Ie
6d4128750b stop append /# before id when no namespace 2016-04-02 01:55:53 +08:00
Zhu Liang
6edcd1c6ba styling fixes 2016-03-31 12:55:42 +08:00
Zhu Liang
6b2394e612 disable loading lib by default to avoid syntax error due to lib containing new es6 syntax 2016-03-31 03:54:32 +08:00
Zhu Liang
677af3fa11 changed env var name, added testing documentation to readme 2016-03-21 13:11:03 +08:00
Zhu Liang
a1ff739b36 babel transpile before test, print error 2016-03-19 20:19:08 +08:00
Zhu Liang
de5b588e17 explicit distinction between current and compat in test so we can serve either compat or current as default 2016-03-19 20:13:57 +08:00
Zhu Liang
5a20c1195b set env vars in travis 2016-03-19 19:49:41 +08:00
Zhu Liang
5253bc400b use multiple npm scripts 2016-03-19 19:41:14 +08:00
Zhu Liang
1245a5639e added compat test 2016-03-19 19:21:54 +08:00
Zhu Liang
88161539a1 implement compat test using env variable 2016-03-17 13:42:29 +08:00
Zhu Liang
d99d4d15ae add compat test for babel-transformed codes 2016-03-17 13:11:20 +08:00
Seth Westphal
06ecfe5444 Explicit local gulp is unnecesary 2016-03-16 13:01:49 -05:00
Seth Westphal
e90b4eba1e Update repository URL 2016-03-16 12:58:59 -05:00
Guillermo Rauch
c7de1a1adf Merge pull request #2471 from nus-fboa2016-si/gulp-rebased
Add gulp and babel
2016-03-12 20:04:48 -08:00
Dan Callahan
7bae6ac636 Fix chat display in Firefox 2016-03-08 19:50:55 -06:00
Diga Widyaprana
355b5156fe Remove node 0.8 from travis 2016-03-09 09:36:51 +08:00
Diga Widyaprana
3e168ee0b8 Redirect make tasks to gulp 2016-03-06 11:40:57 +08:00
Diga Widyaprana
ed9ab77dcb Minor fixes to gulp tasks
- Only provide entry point as first argument of gulp.src
- {read:false} option for mocha tests
- change timeout:2000 to slow:200 to mirror makefile's mocha options
- replace var with const where appropriate
2016-03-06 11:40:57 +08:00
Diga Widyaprana
1104cd135e Use local instead of global gulp in npm test 2016-03-06 11:40:57 +08:00
Diga Widyaprana
0be915cd0f Add gulp task clean to clean transpile output
- Work done by @YijinL. Part of @05ad308
2016-03-06 11:40:57 +08:00
Diga Widyaprana
c6dd41b915 Minor refactoring to transpile task
- Transpiling is now gulp transpile
- Default redirects to transpile
- Refactor transpile output directory to a separate constant
- Work by @YijinL in @05ad308
2016-03-06 11:32:40 +08:00
Diga Widyaprana
0f14312d7b Add gulp help
Work was done by @YijinL in 2 separate commits (@9204125 and @05ad308)
2016-03-06 11:32:09 +08:00
Diga Widyaprana
97bd95f036 Don't use dynamic dependencies 2016-03-04 18:06:00 +08:00
Diga Widyaprana
11e0f19272 Inline babel configuration 2016-03-04 18:06:00 +08:00
Yijin
e388a3319d npm test script to use gulp 2016-03-04 18:06:00 +08:00
Zheng Weihan
b551ce9835 added test-cov task. 2016-03-04 18:06:00 +08:00
Zhu Liang
0bac96a6b2 added comment for babel 2016-03-04 14:46:08 +08:00
Zhu Liang
1d07b10339 integrated babel into gulp 2016-03-04 14:46:08 +08:00
Zheng Weihan
398b5479f0 delete unused dependency 2016-03-04 14:45:55 +08:00
Zheng Weihan
d9eb729eab implement gulp build system for test. 2016-03-04 14:45:03 +08:00
whattokingu
f9db72997f Merge pull request #10 from whattokingu/queryStringFix
Query string fix
2016-02-14 13:57:06 +08:00
Zheng Weihan
1293505dc2 update tests. 2016-02-14 13:48:28 +08:00
Zheng Weihan
f4e9e71c56 Merge branch 'queryStringFix' of https://github.com/whattokingu/socket.io into queryStringFix
# By whattokingu
# Via whattokingu
* 'queryStringFix' of https://github.com/whattokingu/socket.io:
  conform to style guide

Conflicts:
	lib/client.js
2016-02-14 13:47:59 +08:00
Zheng Weihan
045674de97 remove unnecessary decoder. url.parse already decodes string.
add test to test decoding function.
2016-02-14 13:46:26 +08:00
whattokingu
7091acf24c Merge pull request #9 from whattokingu/queryStringFix
Query string fix
2016-02-13 14:41:15 +08:00
whattokingu
19341051e8 conform to style guide 2016-02-13 14:35:12 +08:00
Zheng Weihan
e141e09aaf change decodeUriComponents calls 2016-02-13 14:28:21 +08:00
Zheng Weihan
5fabe4e780 call decodeURIComponent on query received from client.
update package.son to point to latest commit in socket.o-client package (with URI encoder)
2016-02-13 14:10:20 +08:00
whattokingu
7760a71d90 Merge pull request #8 from whattokingu/queryStringFix
add comments to code
2016-02-04 13:28:29 +08:00
Zheng Weihan
c077357eff add comments to code 2016-02-04 13:27:36 +08:00
whattokingu
2f26a2bdb4 Merge pull request #7 from whattokingu/queryStringFix
add test for issue #331 on socket.io-client.
2016-01-31 15:45:35 +08:00
Zheng Weihan
13af610f6d add test for issue #331 on socket.io-client. 2016-01-31 15:44:39 +08:00
whattokingu
abcedf53ec Merge pull request #6 from whattokingu/queryStringFix
sync to master branch
2016-01-31 11:23:02 +08:00
Zheng Weihan
24456fdcbe Merge branch 'master' into queryStringFix
* master:
  Release 1.4.5
  package: bump `engine.io`
  add a test for graceful shutdown
2016-01-31 11:21:30 +08:00
Pedro Narciso García Revington
25116ab179 test node 5 (stable) 2016-01-30 21:53:04 +01:00
Zhu Liang
a116d52e30 updated express version to express 4 2016-01-30 11:57:31 +08:00
whattokingu
cecf5f127e Merge pull request #5 from whattokingu/documentation
Added Documentation
2016-01-30 11:31:11 +08:00
Zheng Weihan
1c467e15e6 Issue #2400, added documentation 2016-01-30 11:28:40 +08:00
whattokingu
a110542563 Merge pull request #4 from whattokingu/queryStringFix
Fix for Issue #331 on socket.io-client
2016-01-30 10:16:19 +08:00
Zheng Weihan
7d55724468 refactor parsing of URL in CONNECT packet to use 'url' library. 2016-01-30 09:47:28 +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
Guillermo Rauch
b3fc530abe Release 1.4.5 2016-01-26 13:26:17 -08:00
Guillermo Rauch
d0dfa54dcb package: bump engine.io 2016-01-26 10:42:41 -08:00
Guillermo Rauch
198b836759 Merge pull request #2399 from nkzawa/graceful-close
Add a test for graceful shutdown
2016-01-21 09:15:36 -08:00
nkzawa
a75f46f06f add a test for graceful shutdown 2016-01-21 20:50:44 +09:00
Naoyuki Kanezawa
2a91fd57c7 Merge pull request #2344 from denghongcai/patch-2
fix wrong jsdoc
2016-01-17 15:25:32 +09:00
Naoyuki Kanezawa
fe891293b2 Merge pull request #2353 from faizalpribadi/patch-1
fix typo word :)
2016-01-17 15:23:35 +09:00
Naoyuki Kanezawa
6e450f75b4 Merge pull request #2374 from darrachequesne/patch-4
Add badges showing dependency status
2016-01-17 15:22:52 +09:00
Naoyuki Kanezawa
22c985cae6 Merge pull request #2380 from darrachequesne/patch-5
Document type change of Socket#rooms
2016-01-17 15:22:05 +09:00
Guillermo Rauch
fea3d79a2c Release 1.4.4 2016-01-10 22:36:31 -08:00
Guillermo Rauch
d3dde130b7 package: bump engine.io 2016-01-10 22:27:44 -08:00
Damien Arrachequesne
899de7f873 Document type change of Socket#rooms 2016-01-09 22:08:30 +01:00
Guillermo Rauch
f1a3e8db2a Release 1.4.3 2016-01-08 08:17:50 -08:00
Guillermo Rauch
dad82c3343 Release 1.4.2 2016-01-07 18:58:05 -08:00
Guillermo Rauch
a6cbf6b205 package: bump engine.io 2016-01-07 18:14:39 -08:00
Damien Arrachequesne
580100d491 Bump dev dependencies 2016-01-07 22:59:28 +01:00
Damien Arrachequesne
acb9cb421d Add badges showing dependency status 2016-01-07 22:58:59 +01:00
Guillermo Rauch
6d5d7e4411 Release 1.4.1 2016-01-07 12:52:27 -08:00
Guillermo Rauch
ddb3445f3d Release 1.4.0 2016-01-05 15:44:48 -08:00
Guillermo Rauch
6eb9807f17 package: bump engine.io for sec advisory 2016-01-05 13:40:54 -08: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
Guillermo Rauch
7b0073c00f Merge pull request #2335 from nkzawa/patch-7
Improve the chat demo
2015-12-04 17:10:23 -08:00
nkzawa
0313ad0ea3 improve the chat demo 2015-12-05 10:07:08 +09:00
Guillermo Rauch
d310d42472 package: bump engine.io 2015-12-04 10:56:08 -08:00
Guillermo Rauch
709ceba00a package: bump socket.io-adapter for release 2015-12-03 10:28:33 -08:00
Guillermo Rauch
b29312bc61 package: bump engine.io for node 0.8 fix 2015-12-01 12:15:36 -08:00
Guillermo Rauch
51901160df package: temporarily revert version for tests 2015-12-01 11:24:06 -08:00
Guillermo Rauch
ab1b36e13f package: bump engine.io for ws memory fix 2015-11-30 08:16:21 -08:00
Guillermo Rauch
f7a2f35590 package: bump engine.io 2015-11-28 16:34:44 -08:00
Guillermo Rauch
c348737fe6 socket.io: increase large binary data test timeout 2015-11-28 15:13:13 -08:00
Guillermo Rauch
dde3737165 package: bump engine.io for release 2015-11-28 12:07:08 -08:00
Guillermo Rauch
8df4c7931b Merge pull request #2325 from darrachequesne/patch-2
Trigger callback even when joining an already joined room
2015-11-28 10:56:46 -08:00
Damien Arrachequesne
1dfacc6647 Trigger callback even when joining an already joined room 2015-11-27 22:08:18 +01:00
Guillermo Rauch
35a0fe0377 package: bump parser 2015-11-25 10:14:56 -08:00
Guillermo Rauch
3b00312fa7 namespace: clear rooms flag after a clients call (fixes #1978) 2015-11-23 09:40:57 -08:00
Guillermo Rauch
7b420295ef Merge pull request #2249 from pmq20/minqi-another
[Travis] Add Node 4.x to the test matrix
2015-11-23 09:31:48 -08:00
Guillermo Rauch
c504315982 Merge pull request #2322 from darrachequesne/issue-2199-clean
Add hasOwnProperty checks
2015-11-23 09:19:35 -08:00
Guillermo Rauch
520b5c37d5 Merge pull request #2321 from nkzawa/patch-6
Update redirects in README
2015-11-23 09:19:03 -08:00
Damien Arrachequesne
09f446eca0 Add hasOwnProperty checks 2015-11-23 15:12:21 +01:00
Naoyuki Kanezawa
aecf3bf71c Merge pull request #2218 from futbalguy/master
Clarified documentation of Socket.in
2015-11-23 17:37:07 +09:00
nkzawa
6c0a79e2b9 update redirects in README 2015-11-23 17:28:11 +09:00
Guillermo Rauch
8683206e31 Merge pull request #2239 from darrachequesne/issue-2199
converted arrays to objects
2015-11-22 10:34:57 -08:00
Guillermo Rauch
988d9d2346 Merge pull request #1999 from nkzawa/patch-3
Fix a few assertions are not executed properly
2015-11-22 10:17:02 -08:00
Damien Arrachequesne
b73d9bea4e converted arrays to objects 2015-11-22 11:12:40 +01:00
Naoyuki Kanezawa
d4fb6a5904 Merge pull request #2316 from tripu/master
Update “debug” to avoid vulnerability in “ms”
2015-11-22 10:39:23 +09:00
tripu
0517c609ba Avoid ^ in "debug" dependency (fixes #2314) 2015-11-21 23:59:16 +01:00
tripu
aa9438fee2 Update package "debug" to avoid "ms" vulnerability 2015-11-21 23:55:00 +01:00
Guillermo Rauch
aee466cc71 Update Readme.md 2015-11-21 10:54:19 -08:00
Guillermo Rauch
65f75d7732 Merge branch 'master' of github.com:socketio/socket.io 2015-11-21 10:46:26 -08:00
Guillermo Rauch
279c52a4c5 package: bump socket.io-parser 2015-11-21 10:45:43 -08:00
Naoyuki Kanezawa
67d1a67b1c Merge pull request #2319 from darrachequesne/patch-3
Minor fix
2015-11-21 23:21:39 +09:00
Damien Arrachequesne
aae68d74b1 Minor performance optimization 2015-11-20 22:03:03 +01:00
Damien Arrachequesne
bf5897cedc Fixed tests with large data 2015-11-20 22:01:16 +01:00
Damien Arrachequesne
a1a1c6657a Removed unused variable 2015-11-20 22:00:42 +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
Naoyuki Kanezawa
dba0576ca9 Merge pull request #2317 from ChaofengZhou/master
fixed a typo in the example code
2015-11-20 13:13:10 +09:00
Chaofeng
ba90f0991b fixed a typo in the example code 2015-11-19 21:09:34 -07:00
Guillermo Rauch
9a54e9cace package: bump mocha 2015-11-18 19:53:25 -08:00
Guillermo Rauch
9df4cb64b8 bump zuul-ngrok 2015-11-18 19:51:47 -08:00
Guillermo Rauch
c8f525868a package: bump has-binary 2015-11-18 16:56:06 -08:00
Guillermo Rauch
a39d7c2ae4 Merge pull request #2171 from KevinMartin/patch-1
Actually prevent double callbacks...
2015-11-18 12:56:01 -08:00
Guillermo Rauch
4ba266d404 Merge pull request #2307 from darrachequesne/patch-1
Upgrade npm version in order to fix node v0.8 build
2015-11-16 15:55:20 -08:00
Damien Arrachequesne
6b49779420 Upgrade npm version in order to fix node v0.8 build 2015-11-17 00:44:42 +01:00
Guillermo Rauch
b1775b1cb8 Merge pull request #2051 from tobalsgithub/master
Allowing a custom function for opts.allowRequest
2015-11-16 13:15:08 -08:00
Guillermo Rauch
ef52967301 Merge pull request #2271 from dazorni/master
Working travis build status
2015-11-16 13:12:26 -08:00
Guillermo Rauch
fde38b1bd7 Merge pull request #2208 from odeke-em/fix-legacy-repo-info
README: fixed up legacy repo links
2015-11-16 13:10:24 -08:00
Sebastian Zorn
75da57abb2 Working travis build status 2015-10-06 21:42:33 +02:00
Guillermo Rauch
21ea31a34e Merge branch '1.3.7-patch' 2015-09-21 04:30:59 +04:00
Guillermo Rauch
e2ebd4349b Release 1.3.7 2015-09-21 04:21:11 +04:00
Guillermo Rauch
b771f74a22 package: bump socket.io-client for node4 compatibility 2015-09-21 04:16:59 +04:00
Guillermo Rauch
8744007dc7 package: bump engine.io for node4 compatibility 2015-09-21 04:10:19 +04:00
P.S.V.R
3658928ee7 [Travis] Add Node 4.x to the test matrix 2015-09-16 17:39:26 +08:00
Guillermo Rauch
210e688732 package: bump engine.io 2015-09-09 15:47:14 -07:00
Guillermo Rauch
ae5420b727 package: bump engine.io and socket.io-client 2015-08-30 10:51:25 -07:00
futbalguy
d5b3bb46f8 Clarified documentation of Socket.in 2015-08-23 10:12:23 -07:00
Emmanuel Odeke
575d35a371 README: fixed up legacy repo links 2015-08-16 20:36:39 -06:00
Guillermo Rauch
e41483be9e Merge branch '1.3.6-patch' 2015-07-14 20:04:44 -07:00
Guillermo Rauch
c79e787671 test: better timeout for stress test 2015-07-14 19:58:42 -07:00
Guillermo Rauch
a2f6bb99d6 Merge branch '1.3.6-patch' 2015-07-14 18:02:56 -07:00
Guillermo Rauch
3e4061bfef Release 1.3.6 2015-07-14 17:59:50 -07:00
Guillermo Rauch
4c1d691fe5 package: bump engine.io to fix build on windows 2015-07-09 09:28:43 -07: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
Nathan Rajlich
876833198d Merge pull request #2111 from kemitchell/spdx-license
Use a Standard-Compliant License Identifier
2015-06-05 11:51:30 -07:00
Naoyuki Kanezawa
4d36d6c01a don't set request property 2015-05-30 03:34:05 +09:00
Guillermo Rauch
43fa075ec4 bump client 2015-05-27 22:56:15 -07:00
Guillermo Rauch
91c7bde34b Merge commit '342faf219793fc5c1f130fc33e3fb5422dab516d' 2015-05-27 22:55:15 -07:00
Guillermo Rauch
874a4a8535 package: bump client 2015-05-27 08:19:15 -07:00
Guillermo Rauch
93b571406e package: bump engine.io to fix build issues 2015-05-25 14:34:10 -07:00
Kyle Mitchell
98af793f07 use a valid SPDX license identifier 2015-05-05 00:08:44 +00: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
Guillermo Rauch
d0d38220fb Update Readme.md 2015-04-08 16:53:04 -07:00
Guillermo Rauch
f8aa157d5d remove proxy index file 2015-04-05 16:53:28 -07:00
Guillermo Rauch
0e13e9a268 bumped adapter 2015-04-05 15:52:59 -07:00
Guillermo Rauch
916872587f Merge pull request #2013 from nkzawa/namespace-flags
Supports flags on namespace
2015-04-05 15:51:54 -07:00
Guillermo Rauch
a7072845ea Merge pull request #2006 from nkzawa/patch-4
improve Socket#packet and Client#packet and enable volatile and compress when broadcast
2015-04-05 15:51:49 -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
Guillermo Rauch
5826ef0bb5 Merge pull request #2059 from rase-/update/debug
Bump debug to 2.1.3
2015-03-17 16:42:00 -07:00
Tony Kovanen
14e32a9bad Bump debug to 2.1.3 2015-03-18 01:40:19 +02:00
TC
1dde0f3947 Allowing a custom function for opts.allowRequest 2015-03-12 15:50:31 -06:00
Guillermo Rauch
342faf2197 Release 1.3.5 2015-03-03 10:50:10 -08:00
Guillermo Rauch
12c6ee132d improve test 2015-03-03 10:34:56 -08:00
Guillermo Rauch
c9d909c993 package: bump socket.io-parser 2015-03-03 10:34:40 -08:00
Guillermo Rauch
125ab51338 test: added test for parser breakage 2015-03-03 10:08:26 -08:00
Guillermo Rauch
b31ac18554 test with 0.12 2015-02-19 15:38:35 -08:00
Naoyuki Kanezawa
53cdd8f1fc support flags on namespace 2015-02-20 03:34:09 +09:00
Naoyuki Kanezawa
81aea995ed improve Socket#packet and Client#packet 2015-02-15 04:33:20 +09:00
Guillermo Rauch
1b2d902f33 Release 1.3.4 2015-02-14 10:57:50 -08:00
Guillermo Rauch
9536437907 package: bump socket.io-client 2015-02-14 10:55:15 -08:00
Naoyuki Kanezawa
56fe26661d fix a few assertions 2015-02-12 06:09:30 +09:00
Guillermo Rauch
29974ac777 Release 1.3.3 2015-02-03 17:27:51 -08:00
Guillermo Rauch
ef23c74bea remove compression tests 2015-02-03 17:07:43 -08:00
Guillermo Rauch
49423d70bc added failing tests 2015-02-03 17:04:33 -08:00
Guillermo Rauch
715c7f99b4 socket: warn node_redis-style about missing error 2015-02-03 17:04:06 -08:00
Guillermo Rauch
f2ea965c6b package: bump parser 2015-02-03 16:32:48 -08:00
Guillermo Rauch
a93d05a9f3 package: bump parser 2015-02-03 16:30:49 -08:00
Guillermo Rauch
5ce06d3088 socket: warn node_redis-style about missing error 2015-02-03 16:26:21 -08:00
Guillermo Rauch
816bfec783 added failing tests 2015-02-03 16:26:08 -08:00
Guillermo Rauch
0a17c90d7a test: added failing test 2015-02-03 15:10:46 -08:00
Guillermo Rauch
3645741b86 test: increase timeout for large binary data test 2015-01-31 09:35:37 -08:00
Guillermo Rauch
f2a7322b5a update deps 2015-01-31 08:46:32 -08:00
Guillermo Rauch
97c6568f65 Merge pull request #1966 from cha0s/clients
Suggestion for implementation of clients API
2015-01-31 08:34:43 -08:00
Ruben Rodriguez II
8814825a35 Suggestion for implementation of clients API 2015-01-31 02:17:49 -06:00
Guillermo Rauch
58eaecad27 Merge branch 'master' of github.com:Automattic/socket.io 2015-01-29 20:39:00 -08:00
Guillermo Rauch
94157e650e point to master 2015-01-29 20:38:36 -08:00
Guillermo Rauch
0935b81da2 Merge pull request #1963 from michael-luo/bugfix/1956
bugfix/1956 test for don't reuse same-namespace connections
2015-01-29 20:34:38 -08:00
Michael Luo
afa871bb8a bugfix/1956 test for don't reuse same-namspace connections 2015-01-24 20:19:16 -08:00
Guillermo Rauch
1b01e16a6c fix broken previous commit 2015-01-24 08:02:05 -08:00
Guillermo Rauch
bd6f638c8f package: bump to work with all objects (fixes #1955) 2015-01-24 07:06:30 -08:00
Guillermo Rauch
83b36e54ac Merge pull request #1958 from nkzawa/compress
Support compression
2015-01-23 10:04:43 -08:00
Guillermo Rauch
2f0d9d05af fix origin verification default https port [evanlucas]
for PR #1693
2015-01-22 21:41:59 +00:00
Naoyuki Kanezawa
429eb0cb7c point to the specific commit 2015-01-22 05:26:37 +09:00
Naoyuki Kanezawa
ac8e8598d7 support compression 2015-01-22 05:01:45 +09:00
Guillermo Rauch
9ba6d47ec7 Release 1.3.2 2015-01-19 15:14:18 +00:00
Guillermo Rauch
3d49cafd03 Release 1.3.1 2015-01-19 11:37:14 +00:00
Guillermo Rauch
77ca2dcbda package: bump engine.io (noop) 2015-01-19 11:11:12 +00:00
Guillermo Rauch
7e4aa4fa64 Release 1.3.0 2015-01-19 10:25:49 +00:00
Guillermo Rauch
b46e480f65 Update Readme.md 2015-01-19 09:26:12 +00:00
Guillermo Rauch
5e92dd8663 package: bump socket.io-client 2015-01-18 19:42:43 +00:00
Guillermo Rauch
f981d3f050 package: bump engine.io 2015-01-18 19:41:45 +00:00
Guillermo Rauch
f57505fee7 Merge branch 'master' of github.com:Automattic/socket.io 2015-01-18 18:53:17 +00:00
Guillermo Rauch
f8f1b132a1 package: bump socket.io-client 2015-01-18 18:52:06 +00:00
Guillermo Rauch
f7f83bc09f package: bump engine.io 2015-01-18 18:51:27 +00:00
Guillermo Rauch
b8ded0d725 Merge pull request #1903 from rase-/add/volatile-tests
Added tests for volatile
2015-01-17 12:23:06 +00:00
Guillermo Rauch
086ccd2708 Merge pull request #1938 from fay-jai/license
update license with up-to-date year range
2015-01-17 12:22:11 +00:00
Guillermo Rauch
864857cb6f Merge pull request #1939 from rase-/add/test-for-emit-after-server-restart
Add test for reconnection after server restarts
2015-01-17 12:21:53 +00:00
Guillermo Rauch
e5a7e422f9 Merge pull request #1943 from eychu/patch-1
Add space in error message
2015-01-17 12:21:38 +00:00
Alexey Chuvashov
f5b75151bd Add space in error message 2015-01-15 01:24:19 +03:00
Tony Kovanen
0523b655da Add test for reconnection after server restarts 2015-01-14 17:22:50 +02:00
Willson Mock
d9415a38e4 update license with up-to-date year range 2015-01-11 00:11:55 -05:00
Roman Shtylman
ca82c09bf2 fix leaving unknown rooms
close #1670
2015-01-10 14:58:50 -08:00
Roman Shtylman
b9aaa1607c Merge pull request #1922 from smart--petea/patch-1
Update Readme.md
2015-01-10 14:48:59 -08:00
Roman Shtylman
d1304c5d82 Merge pull request #1926 from coderaiser/patch-1
package: debug v2.1.0
2015-01-10 14:33:21 -08:00
Guillermo Rauch
bd479a9cd6 Merge pull request #1936 from drewblaisdell/master
Allow null or undefined origins when allowed origins is a function
2015-01-09 16:36:38 -08:00
Drew Blaisdell
a116d7765a Allow null or undefined origins when allowed origins is a function
Requests without an Origin header previously caused an exception to be thrown if the allowed origins passed to the constructor was set to a dynamic function. Omitted origins are now set to an asterisk and passed properly to the origins function.

A test for this case is included in this commit.
2015-01-09 16:30:08 -08:00
Guillermo Rauch
1c6620d564 everything is fixed 2015-01-09 16:25:42 -08:00
Guillermo Rauch
dba462e6da fix tests on 0.11 2015-01-09 16:24:24 -08:00
Guillermo Rauch
19c4422361 package: fix npm test to run on windows 2015-01-09 13:57:45 -08:00
coderaiser
8242dd01ef package: debug v2.1.0 2014-12-26 14:16:27 +02:00
Badarau Petru
17960ed038 Update Readme.md
underylings to underlyings
2014-12-22 07:17:01 +02:00
Tony Kovanen
d9996f0470 Added tests for volatile 2014-12-08 11:19:49 +02:00
Guillermo Rauch
24d06d76dd Release 1.2.1 2014-11-21 04:59:14 +01:00
Guillermo Rauch
4e4bbf918e fix protocol violations and improve error handling (fixes #1880) 2014-11-21 04:16:37 +01:00
Guillermo Rauch
b49f5c82f2 syntax 2014-11-21 04:15:42 +01:00
Guillermo Rauch
5bd67195de Merge branch 'master' of github.com:Automattic/socket.io 2014-11-21 02:57:35 +01:00
Guillermo Rauch
73fe547956 package: bump engine.io for websocket leak fix 2014-11-21 02:56:28 +01:00
Guillermo Rauch
973e6cc982 Merge pull request #1813 from ogwiz2/patch-1
Made comments more consistent
2014-11-12 10:04:09 +01:00
Guillermo Rauch
4a0091b25a Release 1.2.0 2014-10-27 15:54:57 -07:00
Guillermo Rauch
a1bf85b57f package: bump socket.io-parser 2014-10-27 11:52:09 -07:00
Guillermo Rauch
62ad812ee5 package: use latest socket.io-client 2014-10-27 11:51:03 -07:00
Guillermo Rauch
9ae8ed6929 package: bump adapter 2014-10-27 11:46:44 -07:00
Guillermo Rauch
4a11c16cc2 package: bump socket.io-client 2014-10-27 11:09:44 -07:00
Guillermo Rauch
b88a758857 package: bump engine.io 2014-10-27 07:47:51 -07:00
Guillermo Rauch
3352d1d726 Merge branch 'master' of github.com:Automattic/socket.io 2014-10-13 08:52:46 -07:00
Guillermo Rauch
e68557fab6 downloads badge 2014-10-13 08:52:36 -07:00
Alex Jeng
136fe960b7 Made comments more consistent 2014-10-05 22:10:13 -07:00
Tony Kovanen
da358084f0 Merge pull request #1773 from AjayMT/master
Fix usage example for Server#close.
2014-09-26 01:13:18 +03:00
Tony Kovanen
1b4f6a5324 Merge pull request #1777 from akamensky/dynamic-cors
Dynamic cors
2014-09-22 13:38:14 -06:00
Tony Kovanen
99346eddc5 Merge pull request #1788 from jamesanthonyferguson/patch-1
Change grammar issues in the chat/README.md
2014-09-22 12:42:59 -06:00
Tony Kovanen
051ffa0440 Merge pull request #1626 from thanpolas/patch-1
http.Server is a constructor
2014-09-22 12:42:10 -06:00
Tony Kovanen
fa4fa3365a Merge pull request #1690 from rase-/fix/resource-option-bc
Fix resource option BC with the set function
2014-09-22 12:27:35 -06:00
Tony Kovanen
bafa184c6b Merge pull request #1792 from rase-/add/autopruning-test
Add room autopruning test
2014-09-22 12:25:23 -06:00
Tony Kovanen
e3149d5833 Bump adapter version. 2014-09-20 11:12:58 -06:00
Tony Kovanen
ae9d5277a9 Add test to check that empty rooms are autopruned. 2014-09-20 11:12:26 -06:00
James Ferguson
2e440722a6 Change grammar issues in the chat/README.md
Added a few periods and commas which were missing. Also added the word each to clarify how multiple users each enter a unique username.
Very minor edit. No source code changed.
2014-09-18 21:41:28 -07:00
Tony Kovanen
3fe6d4e8ec Merge pull request #1784 from matthewcanty/patch-1
Change "there're" to "there are"
2014-09-17 07:41:46 -06:00
Matthew Canty
3b93c1c562 Change "there're" to "there are"
Not a commonly used contraction and looks a bit odd.
2014-09-17 14:01:01 +01:00
akamensky
e89f82a9b0 Added Server#origins(v:Function) description for dynamic CORS 2014-09-12 11:32:20 +08:00
akamensky
1b90ae2587 Added test coverage for Server#origins(function) for dynamic CORS 2014-09-12 11:13:51 +08:00
akamensky
9658e32e7a Added optional Server#origins(function) for dynamic CORS 2014-09-12 10:53:14 +08:00
Tony Kovanen
99d76664aa Merge pull request #1766 from BrianGeppert/master
package: fix main file for example application 'chat'.
2014-09-11 18:05:58 +03:00
Ajay MT
23eefa527a Fix usage example for Server#close. 2014-09-10 18:11:56 +05:30
Brian Geppert
b49b35b26f package: fix main file for example application 'chat'. 2014-09-04 12:10:43 -05:00
Guillermo Rauch
16483375a7 Release 1.1.0 2014-09-04 12:06:06 +02:00
Guillermo Rauch
ec305bd8df examples: minor fix of escaping 2014-09-04 11:44:02 +02:00
Guillermo Rauch
af07a1c649 package: bump engine.io 2014-09-04 01:57:58 +02:00
Tony Kovanen
5863903d44 Merge pull request #1729 from anupbishnoi/patch-1
Take "" and "/" as equivalent namespaces on server
2014-08-20 11:27:46 +03:00
Anup Bishnoi
f56d4acce6 testing for equivalence of namespaces starting with / or without 2014-08-19 22:19:50 +00:00
Anup Bishnoi
8ea37b7351 Update index.js 2014-08-19 16:17:45 -04:00
Anup Bishnoi
b3cb18d910 Added relevant tests
"" and "/" namespaces are checked for equivalence on server and client
2014-08-18 22:47:06 -04:00
Anup Bishnoi
0e41561d56 Take "" and "/" as equivalent namespaces on server
On server, `.of(name)` should use the same key in `.nsps` object for "" and "/"

Important to use `String(name)` and `===` to keep out keys that don't cast to ""
2014-08-18 22:38:47 -04:00
Guillermo Rauch
83709e9487 Merge pull request #1714 from PeterDaveHello/patch-2
Use svg instead of png to get better image quality
2014-08-12 15:47:12 -07:00
Guillermo Rauch
6f4051aaa7 Merge pull request #1713 from PeterDaveHello/patch-1
make CI build faster
2014-08-12 15:45:58 -07:00
Peter Dave Hello
87bf6910b5 Use svg instead of png to get better image quality 2014-08-12 10:56:04 +08:00
Peter Dave Hello
8946b4ed4c make CI build faster 2014-08-12 10:51:01 +08:00
Guillermo Rauch
a40068b5f3 Merge pull request #1688 from fdellabetta/server_side_namespace
client cannot connect to non-existing namespaces
2014-08-01 13:45:32 +01:00
Guillermo Rauch
9e29ec9b2b Merge pull request #1700 from rase-/fix/rooms
Fix splice arguments and `socket.rooms` value update in `socket.leaveAll`
2014-08-01 13:45:01 +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
b4954d767a Take the instance stored path value into account when attaching to eio if no option specified to attach directly 2014-07-23 19:58:44 +03:00
Filippo Della Betta
f6eb53f5e1 client cannot connect to non-existing namespaces 2014-07-22 13:58:13 +02:00
Guillermo Rauch
9c80317574 Merge pull request #1685 from rase-/fix/remote-address-in-handshake-obj
Fix remote address in handshake obj
2014-07-18 19:47:26 -07:00
Tony Kovanen
d163d891ef Bump engine.io version to get the cached IP address 2014-07-19 04:49:51 +03:00
Tony Kovanen
54726105cb Fixed handshake object address property and made the test case more strict. 2014-07-19 04:43:03 +03:00
Guillermo Rauch
3d9e52cf93 Merge branch 'master' of github.com:Automattic/socket.io 2014-07-17 12:20:17 -07:00
Guillermo Rauch
ad74f2ff88 package: bump engine.io 2014-07-17 12:17:46 -07:00
Guillermo Rauch
cf1c1273b3 Merge pull request #1682 from kevin-roark/fix/disconnect-connectbuffer-crash
Fixed the failing test where server crashes on disconnect involving connectBuffer
2014-07-16 10:58:54 -07:00
Kevin Roark
1f43c4abb5 Fixed the failing test where server crashes on disconnect involving connectBuffer
Source of bug: after connection to nsp '/', the socket's connectBuffer
was being deleted. On attempt to reconnect to a different namespace,
the connect buffer was deleted and we attempted to push to it. Instead
of the deleting the connect buffer, it is now emptied.
2014-07-16 08:35:16 -07:00
Guillermo Rauch
d6e6e8a2f8 Merge pull request #1673 from bryanburgers/patch-1
Fix repo in package.json
2014-07-15 18:25:59 -07:00
Guillermo Rauch
fbd36b613d npmignore: ignore .gitignore (fixes #1607) 2014-07-15 10:55:34 -07:00
Guillermo Rauch
480b1a05bd test: added failing case for socket.disconnect and nsps 2014-07-15 10:52:23 -07:00
Bryan Burgers
ef729b72b4 Fix repo in package.json 2014-07-09 07:28:45 -05:00
Thanasis Polychronakis
63e197083b update README http ctor to createServer() 2014-07-01 10:41:53 +03:00
Guillermo Rauch
968e94e42b Merge pull request #1655 from ysmood/fix_etag_header
We should use the standard http protocol to handler the etag header
2014-06-30 23:32:23 -07:00
Guillermo Rauch
c18ed5fd4d Merge pull request #1646 from narcisoguillen/close_sio
Close sio
2014-06-30 19:10:26 -07:00
Narciso Guillen
1f7da938bd Improve Close documentation 2014-06-30 15:57:21 -05:00
Narciso Guillen
4b89bce182 use ephemeral ports 2014-06-30 15:49:08 -05:00
Yad Smood
8c19eef07a fix: We should use the standard http protocol to handler the etag
header.
2014-06-29 21:42:57 +08:00
Guillermo Rauch
662b30669b Merge pull request #1653 from acusti/patch-1
Override default browser font-family for inputs
2014-06-28 10:55:22 -07:00
Andrew Patton
001373ee17 Override default browser font-family for inputs
For consistent typography, explicitly declare font-family stack for `input` in addition to `html` (in Chrome and Safari on mac, the input will otherwise use default font for such elements, like Lucida Grande)
2014-06-28 13:14:33 -04:00
Guillermo Rauch
246f3bb5c3 Merge pull request #1648 from kevin-roark/update/has-binary-data
update has-binary-data to 1.0.3
2014-06-23 20:20:39 -07:00
Kevin Roark
68d06ec94c update has-binary-data to 1.0.3 2014-06-23 20:19:26 -07:00
Narciso Guillen
a1feca1bd3 Add close specs 2014-06-23 21:03:31 -05:00
Narciso Guillen
968105a239 Add ability to stop the http server even if not created inside socket.io 2014-06-23 21:03:12 -05:00
Narciso Guillen
2e8e26613a Update README 2014-06-23 20:02:39 -05:00
Narciso Guillen
fbdb94d146 make sure server gets close 2014-06-23 19:55:02 -05:00
Tony Kovanen
55572122f3 Merge pull request #1642 from rase-/add/test
Duplicate events test for `reconnect_failed`
2014-06-21 17:28:37 +03:00
Tony Kovanen
a1170a3aa6 Bump client 2014-06-21 17:26:55 +03:00
Tony Kovanen
0954301d7e Add test case for checking that reconnect_failed is fired only once upon failure 2014-06-21 17:14:15 +03:00
Guillermo Rauch
328a9df8eb package: bump socket.io-parser for component-emitter dep fix
cc @davglass @reid
2014-06-20 16:57:54 -07:00
Guillermo Rauch
d99e30fca7 Release 1.0.6 2014-06-19 14:57:50 -07:00
Guillermo Rauch
561dd6fd79 package: bump engine.io for utf8 fix (fixes #1622) 2014-06-19 14:51:37 -07:00
Guillermo Rauch
e9e2a91cea package: bump socket.io-client 2014-06-19 08:05:38 -07:00
Guillermo Rauch
8a3a111a7f Merge pull request #1635 from rase-/add/test
Test for duplicate events on manual reconnect
2014-06-18 15:54:23 -07:00
Tony Kovanen
bd87e4dc35 Bump socket.io-client to latest commit so that duplicate events test passes 2014-06-19 01:52:34 +03:00
Tony Kovanen
71c253e992 Added test for duplicate events after manual reconnects 2014-06-19 01:49:00 +03:00
Guillermo Rauch
a5cf4f57a0 Release 1.0.5 2014-06-17 18:14:44 -07:00
Guillermo Rauch
a079cbc7f9 client: fixes #1632 2014-06-17 18:07:30 -07:00
Guillermo Rauch
14a9fdb64f package: bump engine.io 2014-06-16 08:36:01 -07:00
Thanasis Polychronakis
55fb100fc0 http.Server is a constructor
...and thus requires the `new` keyword
2014-06-14 13:52:36 +03:00
Guillermo Rauch
6159df3937 fixed client 2014-06-13 13:04:50 -07:00
Guillermo Rauch
6f7bab5dfd Merge pull request #1578 from kevin-roark/add/emit-buffer-test
added the client emit-buffer test
2014-06-13 10:10:40 -07:00
Guillermo Rauch
7d2b44e176 index: fix typo [thanks @yanatan16] 2014-06-11 10:42:48 -07:00
Tony Kovanen
0b5fdf995a Merge pull request #1603 from nkzawa/patch-2
Add removeListener to blacklisted events
2014-06-08 14:40:25 +03:00
Naoyuki Kanezawa
a66bea5b33 add removeListener to blacklisted events 2014-06-08 20:34:50 +09:00
Guillermo Rauch
a1a88aaaaf Merge pull request #1600 from poldridge/master
Update index.js
2014-06-06 22:36:19 -07:00
poldridge
3f817c3a18 Update index.js
Added missing hasOwnProperty check. socket.io breaks without it when Object.prototype has been extended.
2014-06-06 22:08:58 -07:00
Guillermo Rauch
99bbd74d14 Merge pull request #1582 from kevin-roark/add/clearer-example-instructions
Add/clearer example instructions
2014-06-02 20:44:34 -07:00
Kevin Roark
398511ddee Merge branch 'upstream' into add/clearer-example-instructions 2014-06-02 20:28:42 -07:00
Kevin Roark
fdf7937815 clearer instructions to install chat example 2014-06-02 20:28:19 -07:00
Guillermo Rauch
475909e642 Release 1.0.4 2014-06-02 20:08:33 -07:00
Guillermo Rauch
95acec8b94 package: bump socket.io-client 2014-06-02 20:07:07 -07:00
Kevin Roark
5812ddf2b0 added the client emit-buffer test 2014-06-01 23:20:42 -07:00
Guillermo Rauch
1bbc3951bd Release 1.0.3 2014-05-31 18:34:50 -07:00
Guillermo Rauch
039eed2c2a package: bump socket.io-client 2014-05-31 09:53:25 -07:00
Guillermo Rauch
6de022b180 Merge pull request #1565 from kevin-roark/add/binary-ack
Add/binary ack
2014-05-31 09:50:19 -07:00
Guillermo Rauch
a06331d29f travis fix 2014-05-30 21:37:22 -07:00
Guillermo Rauch
e639685370 fix travis 2014-05-30 21:23:55 -07:00
Guillermo Rauch
1f2e681ce2 package: bump socket.io-parser for binary ack fix 2014-05-30 21:11:57 -07:00
Kevin Roark
397944fcbe big file tests 2014-05-30 20:40:44 -07:00
Kevin Roark
27dada65b9 distinction between ACK and BINARY_ACK 2014-05-30 18:42:23 -07:00
Guillermo Rauch
99f1ac9aae Merge pull request #1563 from rase-/fix/no-disconnect-fired-for-nsp
Fix namespace iterator in disconnect
2014-05-30 16:40:59 -07:00
Tony Kovanen
ee8d0fbae0 Fix namespace iterator in disconnect 2014-05-31 02:25:28 +03:00
Guillermo Rauch
8e08a6d419 Merge pull request #1562 from rase-/add/utf8-tests
Add test case for emitting multibyte chars
2014-05-30 15:48:34 -07:00
Tony Kovanen
318ae87f50 Add test case for emitting multibyte chars 2014-05-31 01:45:31 +03:00
Guillermo Rauch
2c1b61148d Merge branch 'master' of github.com:automattic/socket.io 2014-05-30 14:14:12 -07:00
Guillermo Rauch
507054c0a8 package: bump engine.io for utf8 binary fix 2014-05-30 14:09:54 -07:00
Tony Kovanen
dfceb006d7 Merge pull request #1554 from grant/master
Fix xss vulnerability in example chat app
2014-05-30 12:15:12 +03:00
Grant Timmerman
4d83456f74 Fix xss vulnerability in example chat app 2014-05-30 02:03:33 -07:00
Tony Kovanen
201aad83b1 Merge pull request #1540 from grant/master
Make chat example wrap long words (no overflow)
2014-05-30 12:02:15 +03:00
Grant Timmerman
72eb61d01f Make chat example wrap long words (no overflow) 2014-05-30 01:44:27 -07:00
Tony Kovanen
163a2a696e Merge pull request #1543 from mohnish/patch-1
Remove obsolete message from README file
2014-05-29 21:33:36 +03:00
Guillermo Rauch
199a479ebc Merge pull request #1545 from overra/patch-1
Use cleanInput() on incoming messages
2014-05-28 20:47:20 -07:00
Guillermo Rauch
d383ff9662 Merge pull request #1546 from hiddenmin/patch-1
Update Readme.md
2014-05-28 19:42:39 -07:00
Amin Cheloh
416b550189 Update Readme.md
socket.io-adapter link
2014-05-29 09:41:37 +07:00
Adam Snodgrass
536b338a01 Use cleanInput() on incoming messages
This prevents XSS if one were to send messages using socket.io from the console.
2014-05-28 20:35:24 -05:00
Mohnish Thallavajhula
a06ae10895 Remove obsolete message from README file 2014-05-28 17:10:50 -07:00
Guillermo Rauch
35a85084b1 Release 1.0.2 2014-05-28 13:24:59 -07:00
Guillermo Rauch
0c2b44a846 package: bump parser for windows fix 2014-05-28 13:23:51 -07:00
Guillermo Rauch
0f6ee2dbd9 travis 2014-05-28 12:56:10 -07:00
25 changed files with 176135 additions and 345 deletions

25
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,25 @@
*Note*: for support questions, please use one of these channels: [stackoverflow](http://stackoverflow.com/questions/tagged/socket.io) or [slack](https://socketio.slack.com)
### You want to:
* [x] report a *bug*
* [ ] request a *feature*
### Current behaviour
### Steps to reproduce (if the current behaviour is a bug)
### Expected behaviour
### Setup
- OS:
- browser:
- socket.io version:
### Other information (e.g. stacktraces, related issues, suggestions how to fix)

18
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,18 @@
### The kind of change this PR does introduce
* [x] a bug fix
* [ ] a new feature
* [ ] an update to the documentation
* [ ] a code change that improves performance
* [ ] other
### Current behaviour
### New behaviour
### Other information (e.g. related issues)

2
.gitignore vendored
View File

@@ -9,3 +9,5 @@ lib-cov
benchmarks/*.png
node_modules
coverage
.idea
dist

View File

@@ -1,3 +0,0 @@
support
test
examples

View File

@@ -1,13 +1,28 @@
sudo: false
before_install:
- npm install -g npm@'>=1.4.3'
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.11"
- "0.12"
- "4"
- "node"
git:
depth: 1
matrix:
fast_finish: true
allow_failures:
- node_js: "0.11"
include:
- node_js: '0.10'
env: TEST_VERSION=compat
- node_js: '0.12'
env: TEST_VERSION=compat
- node_js: '4'
env: TEST_VERSION=compat
#matrix:
#fast_finish: true
#allow_failures:
#- node_js: "0.11"
notifications:
irc: "irc.freenode.org#socket.io"

View File

@@ -1,4 +1,239 @@
1.5.1 / 2016-10-24
==================
* [fix] Avoid swallowing exceptions thrown by user event handlers (#2682)
* [test] Use client function to unify `client` in test script (#2731)
* [docs] Add link to LICENSE (#2221)
* [docs] Fix JSDoc of optional parameters (#2465)
* [docs] Fix typo (#2724)
* [docs] Link readme npm package badge to npm registry page (#2612)
* [docs] Minor fixes (#2526)
* [chore] Bump socket.io-parser to 2.3.0 (#2730)
* [chore] Add Github issue and PR templates (#2733)
* [chore] Bump engine.io to 1.7.2 (#2729)
* [chore] Bump socket.io-parser to 2.3.1 (#2734)
1.5.0 / 2016-10-06
==================
* [feature] stop append /# before id when no namespace (#2508)
* [feature] Add a 'disconnecting' event to access to socket.rooms upon disconnection (#2332)
* [fix] Fix query string management (#2422)
* [fix] add quote to exec paths, prevent error when spaces in path (#2508)
* [docs] Prevent mixup for new programmers (#2599)
* [example] Fix chat display in Firefox (#2477)
* [chore] Add gulp & babel in the build process (#2471)
* [chore] Bump engine.io to 1.7.0 (#2707)
* [chore] Remove unused zuul-ngrok dependency (#2708)
* [chore] Point towards current master of socket.io-client (#2710)
* [chore] Restrict files included in npm package (#2709)
* [chore] Link build badge to master branch (#2549)
1.4.8 / 2016-06-23
==================
* package: bump `engine.io`
1.4.7 / 2016-06-23
==================
* package: bump `engine.io`
1.4.6 / 2016-05-02
==================
* package: bump engine.io
1.4.5 / 2016-01-26
==================
* fix closing the underlying `http.Server`
1.4.4 / 2016-01-10
==================
* package: bump `engine.io`
1.4.3 / 2016-01-08
==================
* bump `socket.io-client`
1.4.2 / 2016-01-07
==================
* bump `engine.io`
1.4.1 / 2016-01-07
==================
* version bump
1.4.0 / 2015-11-28
==================
* socket.io: increase large binary data test timeout
* package: bump `engine.io` for release
* trigger callback even when joining an already joined room
* package: bump parser
* namespace: clear rooms flag after a clients call (fixes #1978)
* package: bump `socket.io-parser`
* fixed tests with large data
* fixed a typo in the example code
* package: bump mocha
* package: bump `has-binary` and `zuul-ngrok`
* package: bump `engine.io` and `socket.io-client`
* README: clarified documentation of Socket.in
* README: fixed up legacy repo links
* test: better timeout for stress test
* socket: don't set request property which has a getter
* removed proxy index file
* support flags on namespace
* improve Socket#packet and Client#packet
* socket: warn node_redis-style about missing `error`
* test: added failing test
* test: increase timeout for large binary data test
* package: bump `has-binary` to work with all objects (fixes #1955)
* fix origin verification default https port [evanlucas]
* support compression [nkzawa]
* changed type of `Client#sockets`, `Namespace#sockets` and `Socket#rooms` to maps (instead of arrays)
1.3.7 / 2015-09-21
==================
* package: bump `socket.io-client` for node4 compatibility
* package: bump `engine.io` for node4 compatibility
1.3.6 / 2015-07-14
==================
* package: bump `engine.io` to fix build on windows
1.3.5 / 2015-03-03
==================
* package: bump `socket.io-parser`
1.3.4 / 2015-02-14
==================
* package: bump `socket.io-client`
1.3.3 / 2015-02-03
==================
* socket: warn node_redis-style about missing `error`
* package: bump parser to better handle bad binary packets
1.3.2 / 2015-01-19
==================
* no change on this release
1.3.1 / 2015-01-19
==================
* no change on this release
* package: bump `engine.io`
1.3.0 / 2015-01-19
==================
* package: bump `engine.io`
* add test for reconnection after server restarts [rase-]
* update license with up-to-date year range [fay-jai]
* fix leaving unknown rooms [defunctzombie]
* allow null origins when allowed origins is a function [drewblaisdell]
* fix tests on node 0.11
* package: fix `npm test` to run on windows
* package: bump `debug` v2.1.0 [coderaiser]
* added tests for volatile [rase-]
1.2.1 / 2014-11-21
==================
* fix protocol violations and improve error handling (GH-1880)
* package: bump `engine.io` for websocket leak fix [3rd-Eden]
* style tweaks
1.2.0 / 2014-10-27
==================
* package: bump `engine.io`
* downloads badge
* add test to check that empty rooms are autopruned
* added Server#origins(v:Function) description for dynamic CORS
* added test coverage for Server#origins(function) for dynamic CORS
* added optional Server#origins(function) for dynamic CORS
* fix usage example for Server#close
* package: fix main file for example application 'chat'
* package: bump `socket.io-parser`
* update README http ctor to createServer()
* bump adapter with a lot of fixes for room bookkeeping
1.1.0 / 2014-09-04
==================
* examples: minor fix of escaping
* testing for equivalence of namespaces starting with / or without
* update index.js
* added relevant tests
* take "" and "/" as equivalent namespaces on server
* use svg instead of png to get better image quality in readme
* make CI build faster
* fix splice arguments and `socket.rooms` value update in `socket.leaveAll`.
* client cannot connect to non-existing namespaces
* bump engine.io version to get the cached IP address
* fixed handshake object address property and made the test case more strict.
* package: bump `engine.io`
* fixed the failing test where server crashes on disconnect involving connectBuffer
* npmignore: ignore `.gitignore` (fixes #1607)
* test: added failing case for `socket.disconnect` and nsps
* fix repo in package.json
* improve Close documentation
* use ephemeral ports
* fix: We should use the standard http protocol to handler the etag header.
* override default browser font-family for inputs
* update has-binary-data to 1.0.3
* add close specs
* add ability to stop the http server even if not created inside socket.io
* make sure server gets close
* Add test case for checking that reconnect_failed is fired only once upon failure
* package: bump `socket.io-parser` for `component-emitter` dep fix
1.0.6 / 2014-06-19
==================
* package: bump `socket.io-client`
1.0.5 / 2014-06-16
==================
* package: bump `engine.io` to fix jsonp `\n` bug and CORS warnings
* index: fix typo [yanatan16]
* add `removeListener` to blacklisted events
* examples: clearer instructions to install chat example
* index: fix namespace `connectBuffer` issue
1.0.4 / 2014-06-02
==================
* package: bump socket.io-client
1.0.3 / 2014-05-31
==================
* package: bump `socket.io-client`
* package: bump `socket.io-parser` for binary ACK fix
* package: bump `engine.io` for binary UTF8 fix
* example: fix XSS in chat example
1.0.2 / 2014-05-28
==================
* package: bump `socket.io-parser` for windows fix
1.0.1 / 2014-05-28
==================

View File

@@ -1,6 +1,6 @@
(The MIT License)
Copyright (c) 2014 Automattic <dev@cloudup.com>
Copyright (c) 2014-2015 Automattic <dev@cloudup.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@@ -1,15 +1,8 @@
REPORTER = dot
test:
@./node_modules/.bin/mocha \
--reporter $(REPORTER) \
--slow 200ms \
--bail
@./node_modules/.bin/gulp test
test-cov:
@./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- \
--reporter $(REPORTER) \
test/
@./node_modules/.bin/gulp test-cov
.PHONY: test

190
Readme.md
View File

@@ -1,11 +1,12 @@
### This Readme corresponds to the upcoming 1.0 release. Please refer to http://socket.io for the current 0.9.x documentation.
<hr />
# socket.io
[![Build Status](https://secure.travis-ci.org/LearnBoost/socket.io.png)](http://travis-ci.org/LearnBoost/socket.io)
[![NPM version](https://badge.fury.io/js/socket.io.png)](http://badge.fury.io/js/socket.io)
[![Build Status](https://secure.travis-ci.org/socketio/socket.io.svg?branch=master)](https://travis-ci.org/socketio/socket.io)
[![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)
[![](http://slack.socket.io/badge.svg?)](http://slack.socket.io)
## How to use
@@ -13,11 +14,11 @@ The following example attaches socket.io to a plain Node.JS
HTTP server listening on port `3000`.
```js
var server = require('http').Server();
var server = require('http').createServer();
var io = require('socket.io')(server);
io.on('connection', function(socket){
socket.on('event', function(data){});
socket.on('disconnect', function(){});
io.on('connection', function(client){
client.on('event', function(data){});
client.on('disconnect', function(){});
});
server.listen(3000);
```
@@ -26,7 +27,7 @@ server.listen(3000);
```js
var io = require('socket.io')();
io.on('connection', function(socket){});
io.on('connection', function(client){});
io.listen(3000);
```
@@ -39,7 +40,7 @@ function.
```js
var app = require('express')();
var server = require('http').Server(app);
var server = require('http').createServer(app);
var io = require('socket.io')(server);
io.on('connection', function(){ /* … */ });
server.listen(3000);
@@ -52,7 +53,7 @@ handler function, but only by calling the `callback` method.
```js
var app = require('koa')();
var server = require('http').Server(app.callback());
var server = require('http').createServer(app.callback());
var io = require('socket.io')(server);
io.on('connection', function(){ /* … */ });
server.listen(3000);
@@ -87,7 +88,7 @@ server.listen(3000);
The same options passed to socket.io are always passed to
the `engine.io` `Server` that gets created. See engine.io
[options](https://github.com/learnboost/engine.io#methods-1)
[options](https://github.com/socketio/engine.io#methods-1)
as reference.
### Server(srv:http#Server, opts:Object)
@@ -129,7 +130,7 @@ server.listen(3000);
Sets the adapter `v`. Defaults to an instance of the `Adapter` that
ships with socket.io which is memory based. See
[socket.io-adapter](https://github.com/learnboost/socket.io-adapter).
[socket.io-adapter](https://github.com/socketio/socket.io-adapter).
If no arguments are supplied this method returns the current value.
@@ -139,6 +140,15 @@ server.listen(3000);
If no arguments are supplied this method returns the current value.
### Server#origins(v:Function):Server
Sets the allowed origins as dynamic function. Function takes two arguments `origin:String` and `callback(error, success)`, where `success` is a boolean value indicating whether origin is allowed or not.
__Potential drawbacks__:
* in some situations, when it is not possible to determine `origin` it may have value of `*`
* As this function will be executed for every request, it is advised to make this function work as fast as possible
* If `socket.io` is used together with `Express`, the CORS headers will be affected only for `socket.io` requests. For Express can use [cors](https://github.com/expressjs/cors)
### Server#sockets:Namespace
@@ -160,7 +170,7 @@ server.listen(3000);
### Server#bind(srv:engine#Server):Server
Advanced use only. Binds the server to a specific engine.io `Server`
Advanced use only. Binds the server to a specific engine.io `Server`
(or compatible API) instance.
### Server#onconnection(socket:engine#Socket):Server
@@ -170,14 +180,14 @@ server.listen(3000);
### Server#of(nsp:String):Namespace
Initializes and retrieves the given `Namespace` by its pathname
Initializes and retrieves the given `Namespace` by its pathname
identifier `nsp`.
If the namespace was already initialized it returns it right away.
### Server#emit
Emits an event to all connected clients. The following two are
Emits an event to all connected clients. The following two are
equivalent:
```js
@@ -188,6 +198,24 @@ server.listen(3000);
For other available methods, see `Namespace` below.
### Server#close
Closes socket.io server
```js
var Server = require('socket.io');
var PORT = 3030;
var server = require('http').Server();
var io = Server(PORT);
io.close(); // Close current server
server.listen(PORT); // PORT is free to use
io = Server(server);
```
### Server#use
See `Namespace#use` below.
@@ -215,6 +243,40 @@ server.listen(3000);
Hash of `Socket` objects that are connected to this namespace indexed
by `id`.
### Namespace#clients(fn:Function)
Gets a list of client IDs connected to this namespace (across all nodes if applicable).
An example to get all clients in a namespace:
```js
var io = require('socket.io')();
io.of('/chat').clients(function(error, clients){
if (error) throw error;
console.log(clients); // => [PZDoMHjiu8PYfRiKAAAF, Anw2LatarvGVVXEIAAAD]
});
```
An example to get all clients in namespace's room:
```js
var io = require('socket.io')();
io.of('/chat').in('general').clients(function(error, clients){
if (error) throw error;
console.log(clients); // => [Anw2LatarvGVVXEIAAAD]
});
```
As with broadcasting, the default is all clients from the default namespace ('/'):
```js
var io = require('socket.io')();
io.clients(function(error, clients){
if (error) throw error;
console.log(clients); // => [6em3d4TJP8Et9EMNAAAA, G5p55dHhGgUnLUctAAAB]
});
```
### Namespace#use(fn:Function):Namespace
Registers a middleware, which is a function that gets executed for
@@ -238,10 +300,14 @@ server.listen(3000);
A `Socket` is the fundamental class for interacting with browser
clients. A `Socket` belongs to a certain `Namespace` (by default `/`)
and uses an underlying `Client` to communicate.
It should be noted the `Socket` doesn't relate directly to the actual
underlying TCP/IP `socket` and it is only the name of the class.
### Socket#rooms:Array
### Socket#rooms:Object
A list of strings identifying the rooms this socket is in.
A hash of strings identifying the rooms this client is in, indexed by
room name.
### Socket#client:Client
@@ -249,8 +315,9 @@ server.listen(3000);
### Socket#conn:Socket
A reference to the underyling `Client` transport connection (engine.io
`Socket` object).
A reference to the underlying `Client` transport connection (engine.io
`Socket` object). This allows access to the IO transport layer, which
still (mostly) abstracts the actual TCP/IP socket.
### Socket#request:Request
@@ -260,62 +327,100 @@ server.listen(3000);
### Socket#id:String
A unique identifier for the socket session, that comes from the
A unique identifier for the session, that comes from the
underlying `Client`.
### Socket#emit(name:String[, …]):Socket
Emits an event to the socket identified by the string `name`. Any
other parameters can be included.
Emits an event identified by the string `name` to the client.
Any other parameters can be included.
All datastructures are supported, including `Buffer`. JavaScript
functions can't be serialized/deserialized.
```js
var io = require('socket.io')();
io.on('connection', function(socket){
socket.emit('an event', { some: 'data' });
io.on('connection', function(client){
client.emit('an event', { some: 'data' });
});
```
### Socket#join(name:String[, fn:Function]):Socket
Adds the socket to the `room`, and fires optionally a callback `fn`
Adds the client to the `room`, and fires optionally a callback `fn`
with `err` signature (if any).
The socket is automatically a member of a room identified with its
The client is automatically a member of a room identified with its
session id (see `Socket#id`).
The mechanics of joining rooms are handled by the `Adapter`
that has been configured (see `Server#adapter` above), defaulting to
[socket.io-adapter](https://github.com/socket.io/socket.io-adapter).
[socket.io-adapter](https://github.com/socketio/socket.io-adapter).
### Socket#leave(name:String[, fn:Function]):Socket
Removes the socket from `room`, and fires optionally a callback `fn`
Removes the client from `room`, and fires optionally a callback `fn`
with `err` signature (if any).
**Rooms are left automatically upon disconnection**.
The mechanics of leaving rooms are handled by the `Adapter`
that has been configured (see `Server#adapter` above), defaulting to
[socket.io-adapter](https://github.com/socket.io/socket.io-adapter).
[socket.io-adapter](https://github.com/socketio/socket.io-adapter).
### Socket#to(room:String):Socket
### Socket#in(room:String):Socket
Sets a modifier for a subsequent event emission that the event will
only be _broadcasted_ to sockets that have joined the given `room`.
only be _broadcasted_ to clients that have joined the given `room`.
To emit to multiple rooms, you can call `to` several times.
```js
var io = require('socket.io')();
io.on('connection', function(socket){
socket.to('others').emit('an event', { some: 'data' });
io.on('connection', function(client){
client.to('others').emit('an event', { some: 'data' });
});
```
### Socket#in(room:String):Socket
Same as `Socket#to`
### Socket#compress(v:Boolean):Socket
Sets a modifier for a subsequent event emission that the event data will
only be _compressed_ if the value is `true`. Defaults to `true` when you don't call the method.
```js
var io = require('socket.io')();
io.on('connection', function(client){
client.compress(false).emit('an event', { some: 'data' });
});
```
### Socket#disconnect(close:Boolean):Socket
Disconnects this client. If value of close is `true`, closes the underlying connection.
Otherwise, it just disconnects the namespace.
#### Events
- `disconnect`
- Fired upon disconnection.
- **Arguments**
- `String`: the reason of the disconnection (either client or server-side)
- `error`
- Fired when an error occurs.
- **Arguments**
- `Object`: error data
- `disconnecting`
- Fired when the client is going to be disconnected (but hasn't left its `rooms` yet).
- **Arguments**
- `String`: the reason of the disconnection (either client or server-side)
These are reserved events (along with `connect`, `newListener` and `removeListener`) which cannot be used as event names.
### Client
The `Client` class represents an incoming transport (engine.io)
@@ -334,7 +439,7 @@ server.listen(3000);
## Debug / logging
Socket.IO is powered by [debug](http://github.com/visionmedia/debug).
Socket.IO is powered by [debug](https://github.com/visionmedia/debug).
In order to see all the debug output, run your app with the environment variable
`DEBUG` including the desired scope.
@@ -344,6 +449,17 @@ To see the output from all of Socket.IO's debugging scopes you can use:
DEBUG=socket.io* node myapp
```
## Testing
```
npm test
```
This runs the `gulp` task `test`. By default the test will be run with the source code in `lib` directory.
Set the environmental variable `TEST_VERSION` to `compat` to test the transpiled es5-compat version of the code.
The `gulp` task `test` will always transpile the source code into es5 and export to `dist` first before running the test.
## License
MIT
[MIT](LICENSE)

View File

@@ -6,17 +6,20 @@ A simple chat demo for socket.io
## How to use
```
$ cd socket.io
$ npm install
$ cd examples/chat
$ npm install
$ node .
```
And point your browser to `http://localhost:3000`. Optionally specify
And point your browser to `http://localhost:3000`. Optionally, specify
a port by supplying the `PORT` env variable.
## Features
- Multiple users can join a chat room by entering a unique username
- Multiple users can join a chat room by each entering a unique username
on website load.
- Users can type chat messages to the chat room
- Users can type chat messages to the chat room.
- A notification is sent to all users when a user joins or leaves
the chatroom
the chatroom.

View File

@@ -14,8 +14,6 @@ app.use(express.static(__dirname + '/public'));
// Chatroom
// usernames which are currently connected to the chat
var usernames = {};
var numUsers = 0;
io.on('connection', function (socket) {
@@ -32,10 +30,10 @@ io.on('connection', function (socket) {
// when the client emits 'add user', this listens and executes
socket.on('add user', function (username) {
if (addedUser) return;
// we store the username in the socket session for this client
socket.username = username;
// add the client's username to the global list
usernames[username] = username;
++numUsers;
addedUser = true;
socket.emit('login', {
@@ -64,9 +62,7 @@ io.on('connection', function (socket) {
// when the user disconnects.. perform this
socket.on('disconnect', function () {
// remove the username from global usernames list
if (addedUser) {
delete usernames[socket.username];
--numUsers;
// echo globally that this client has left

View File

@@ -2,11 +2,11 @@
"name": "socket.io-chat",
"version": "0.0.0",
"description": "A simple chat client using socket.io",
"main": "app.js",
"main": "index.js",
"author": "Grant Timmerman",
"private": true,
"license": "BSD",
"dependencies": {
"express": "3.4.8"
"express": "4.13.4"
}
}
}

View File

@@ -7,7 +7,7 @@ $(function() {
'#3b88eb', '#3824aa', '#a700ff', '#d300e7'
];
// Initialize varibles
// Initialize variables
var $window = $(window);
var $usernameInput = $('.usernameInput'); // Input for username
var $messages = $('.messages'); // Messages area
@@ -30,7 +30,7 @@ $(function() {
if (data.numUsers === 1) {
message += "there's 1 participant";
} else {
message += "there're " + data.numUsers + " participants";
message += "there are " + data.numUsers + " participants";
}
log(message);
}
@@ -70,8 +70,8 @@ $(function() {
// Log a message
function log (message, options) {
var el = '<li class="log">' + message + '</li>';
addMessageElement(el, options);
var $el = $('<li>').addClass('log').text(message);
addMessageElement($el, options);
}
// Adds the visual chat message to the message list
@@ -84,16 +84,17 @@ $(function() {
$typingMessages.remove();
}
var colorStyle = 'style="color:' + getUsernameColor(data.username) + '"';
var usernameDiv = '<span class="username"' + colorStyle + '>' +
data.username + '</span>';
var messageBodyDiv = '<span class="messageBody">' +
data.message + '</span>';
var $usernameDiv = $('<span class="username"/>')
.text(data.username)
.css('color', getUsernameColor(data.username));
var $messageBodyDiv = $('<span class="messageBody">')
.text(data.message);
var typingClass = data.typing ? 'typing' : '';
var messageDiv = '<li class="message ' + typingClass + '">' +
usernameDiv + messageBodyDiv + '</li>';
var $messageDiv = $(messageDiv).data('username', data.username);
var $messageDiv = $('<li class="message"/>')
.data('username', data.username)
.addClass(typingClass)
.append($usernameDiv, $messageBodyDiv);
addMessageElement($messageDiv, options);
}
@@ -145,7 +146,7 @@ $(function() {
// Prevents input from having injected markup
function cleanInput (input) {
return $('<div/>').text(input).html() || input;
return $('<div/>').text(input).text();
}
// Updates the typing event
@@ -228,7 +229,7 @@ $(function() {
socket.on('login', function (data) {
connected = true;
// Display the welcome message
var message = "Welcome to Socket.IO Chat &mdash; ";
var message = "Welcome to Socket.IO Chat ";
log(message, {
prepend: true
});
@@ -262,4 +263,4 @@ $(function() {
socket.on('stop typing', function (data) {
removeChatTyping(data);
});
});
});

View File

@@ -5,6 +5,11 @@
}
html {
font-weight: 300;
-webkit-font-smoothing: antialiased;
}
html, input {
font-family:
"HelveticaNeue-Light",
"Helvetica Neue Light",
@@ -13,8 +18,6 @@ html {
Arial,
"Lucida Grande",
sans-serif;
font-weight: 300;
-webkit-font-smoothing: antialiased;
}
html, body {
@@ -25,6 +28,7 @@ html, body {
ul {
list-style: none;
word-wrap: break-word;
}
/* Pages */
@@ -124,7 +128,6 @@ ul {
}
.username {
float: left;
font-weight: 700;
overflow: hidden;
padding-right: 15px;
@@ -143,4 +146,4 @@ ul {
position: absolute;
right: 0;
width: 100%;
}
}

69
gulpfile.js Normal file
View File

@@ -0,0 +1,69 @@
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const babel = require("gulp-babel");
const istanbul = require('gulp-istanbul');
const help = require('gulp-task-listing');
const del = require('del');
gulp.task('help', help);
gulp.task('default', ['transpile']);
const TRANSPILE_DEST_DIR = './dist';
// By default, individual js files are transformed by babel and exported to /dist
gulp.task('transpile', function () {
return gulp.src("lib/*.js")
.pipe(babel({ "presets": ["es2015"] }))
.pipe(gulp.dest(TRANSPILE_DEST_DIR));
});
gulp.task('clean', function () {
return del([TRANSPILE_DEST_DIR]);
})
gulp.task('test', ['transpile'], function(){
return gulp.src('test/socket.io.js', {read: false})
.pipe(mocha({
slow: 200,
reporter: 'spec',
bail: true,
timeout: 10000
}))
.once('error', function (err) {
console.error(err.stack);
process.exit(1);
})
.once('end', function () {
process.exit();
});
});
gulp.task('set-compat-node-env', function() {
process.env.TEST_VERSION = 'compat';
});
gulp.task('test-compat', ['set-compat-node-env', 'test']);
gulp.task('istanbul-pre-test', function () {
return gulp.src(['lib/**/*.js'])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('test-cov', ['istanbul-pre-test'], function(){
return gulp.src('test/socket.io.js', {read: false})
.pipe(mocha({
reporter: 'dot'
}))
.pipe(istanbul.writeReports())
.once('error', function (err){
console.error(err.stack);
process.exit(1);
})
.once('end', function (){
process.exit();
});
});

View File

@@ -1,2 +0,0 @@
module.exports = require('./lib');

View File

@@ -5,6 +5,7 @@
var parser = require('socket.io-parser');
var debug = require('debug')('socket.io:client');
var url = require('url');
/**
* Module exports.
@@ -16,7 +17,7 @@ module.exports = Client;
* Client constructor.
*
* @param {Server} server instance
* @param {Socket} connection
* @param {Socket} conn
* @api private
*/
@@ -28,7 +29,7 @@ function Client(server, conn){
this.id = conn.id;
this.request = conn.request;
this.setup();
this.sockets = [];
this.sockets = {};
this.nsps = {};
this.connectBuffer = [];
}
@@ -42,35 +43,43 @@ function Client(server, conn){
Client.prototype.setup = function(){
this.onclose = this.onclose.bind(this);
this.ondata = this.ondata.bind(this);
this.onerror = this.onerror.bind(this);
this.ondecoded = this.ondecoded.bind(this);
this.decoder.on('decoded', this.ondecoded);
this.conn.on('data', this.ondata);
this.conn.on('error', this.onerror);
this.conn.on('close', this.onclose);
};
/**
* Connects a client to a namespace.
*
* @param {String} namespace name
* @param {String} name namespace
* @api private
*/
Client.prototype.connect = function(name){
Client.prototype.connect = function(name, query){
debug('connecting to namespace %s', name);
var nsp = this.server.of(name);
var nsp = this.server.nsps[name];
if (!nsp) {
this.packet({ type: parser.ERROR, nsp: name, data : 'Invalid namespace'});
return;
}
if ('/' != name && !this.nsps['/']) {
this.connectBuffer.push(name);
return;
}
var self = this;
var socket = nsp.add(this, function(){
self.sockets.push(socket);
var socket = nsp.add(this, query, function(){
self.sockets[socket.id] = socket;
self.nsps[nsp.name] = socket;
if ('/' == nsp.name) {
if ('/' == nsp.name && self.connectBuffer.length > 0) {
self.connectBuffer.forEach(self.connect, self);
delete self.connectBuffer;
self.connectBuffer = [];
}
});
};
@@ -82,12 +91,12 @@ Client.prototype.connect = function(name){
*/
Client.prototype.disconnect = function(){
var socket;
// we don't use a for loop because the length of
// `sockets` changes upon each iteration
while (socket = this.sockets.shift()) {
socket.disconnect();
for (var id in this.sockets) {
if (this.sockets.hasOwnProperty(id)) {
this.sockets[id].disconnect();
}
}
this.sockets = {};
this.close();
};
@@ -98,10 +107,9 @@ Client.prototype.disconnect = function(){
*/
Client.prototype.remove = function(socket){
var i = this.sockets.indexOf(socket);
if (~i) {
var nsp = this.sockets[i].nsp.name;
this.sockets.splice(i, 1);
if (this.sockets.hasOwnProperty(socket.id)) {
var nsp = this.sockets[socket.id].nsp.name;
delete this.sockets[socket.id];
delete this.nsps[nsp];
} else {
debug('ignoring remove for %s', socket.id);
@@ -126,25 +134,25 @@ Client.prototype.close = function(){
* Writes a packet to the transport.
*
* @param {Object} packet object
* @param {Boolean} whether packet is already encoded
* @param {Boolean} whether packet is volatile
* @param {Object} opts
* @api private
*/
Client.prototype.packet = function(packet, preEncoded, volatile){
Client.prototype.packet = function(packet, opts){
opts = opts || {};
var self = this;
// this writes to the actual connection
function writeToEngine(encodedPackets) {
if (volatile && !self.conn.transport.writable) return;
if (opts.volatile && !self.conn.transport.writable) return;
for (var i = 0; i < encodedPackets.length; i++) {
self.conn.write(encodedPackets[i]);
self.conn.write(encodedPackets[i], { compress: opts.compress });
}
}
if ('open' == this.conn.readyState) {
debug('writing packet %j', packet);
if(!preEncoded) { // not broadcasting, need to encode
if (!opts.preEncoded) { // not broadcasting, need to encode
this.encoder.encode(packet, function (encodedPackets) { // encode, then write results to engine
writeToEngine(encodedPackets);
});
@@ -163,7 +171,12 @@ Client.prototype.packet = function(packet, preEncoded, volatile){
*/
Client.prototype.ondata = function(data){
this.decoder.add(data);
// try/catch is needed for protocol violations (GH-1880)
try {
this.decoder.add(data);
} catch(e) {
this.onerror(e);
}
};
/**
@@ -174,17 +187,35 @@ Client.prototype.ondata = function(data){
Client.prototype.ondecoded = function(packet) {
if (parser.CONNECT == packet.type) {
this.connect(packet.nsp);
this.connect(url.parse(packet.nsp).pathname, url.parse(packet.nsp, true).query);
} else {
var socket = this.nsps[packet.nsp];
if (socket) {
socket.onpacket(packet);
process.nextTick(function() {
socket.onpacket(packet);
});
} else {
debug('no socket for namespace %s', packet.nsp);
}
}
};
/**
* Handles an error.
*
* @param {Object} err object
* @api private
*/
Client.prototype.onerror = function(err){
for (var id in this.sockets) {
if (this.sockets.hasOwnProperty(id)) {
this.sockets[id].onerror(err);
}
}
this.onclose('client error');
};
/**
* Called upon transport close.
*
@@ -199,9 +230,12 @@ Client.prototype.onclose = function(reason){
this.destroy();
// `nsps` and `sockets` are cleaned up seamlessly
this.sockets.forEach(function(socket){
socket.onclose(reason);
});
for (var id in this.sockets) {
if (this.sockets.hasOwnProperty(id)) {
this.sockets[id].onclose(reason);
}
}
this.sockets = {};
this.decoder.destroy(); // clean up decoder
};
@@ -214,6 +248,7 @@ Client.prototype.onclose = function(reason){
Client.prototype.destroy = function(){
this.conn.removeListener('data', this.ondata);
this.conn.removeListener('error', this.onerror);
this.conn.removeListener('close', this.onclose);
this.decoder.removeListener('decoded', this.ondecoded);
};

View File

@@ -5,7 +5,6 @@
var http = require('http');
var read = require('fs').readFileSync;
var parse = require('url').parse;
var engine = require('engine.io');
var client = require('socket.io-client');
var clientVersion = require('socket.io-client/package').version;
@@ -30,8 +29,8 @@ var clientSource = read(require.resolve('socket.io-client/socket.io.js'), 'utf-8
/**
* Server constructor.
*
* @param {http.Server|Number|Object} http server, port or options
* @param {Object} options
* @param {http.Server|Number|Object} srv http server, port or options
* @param {Object} [opts]
* @api public
*/
@@ -54,21 +53,25 @@ function Server(srv, opts){
/**
* Server request verification function, that checks for allowed origins
*
* @param {http.IncomingMessage} request
* @param {Function} callback to be called with the result: `fn(err, success)`
* @param {http.IncomingMessage} req request
* @param {Function} fn callback to be called with the result: `fn(err, success)`
*/
Server.prototype.checkRequest = function(req, fn) {
var origin = req.headers.origin || req.headers.referer;
// file:// URLs produce a null Origin which can't be authorized via echo-back
if ('null' == origin) origin = '*';
if ('null' == origin || null == origin) origin = '*';
if (!!origin && typeof(this._origins) == 'function') return this._origins(origin, fn);
if (this._origins.indexOf('*:*') !== -1) return fn(null, true);
if (origin) {
try {
var parts = url.parse(origin);
parts.port = parts.port || 80;
var defaultPort = 'https:' == parts.protocol ? 443 : 80;
parts.port = parts.port != null
? parts.port
: defaultPort;
var ok =
~this._origins.indexOf(parts.hostname + ':' + parts.port) ||
~this._origins.indexOf(parts.hostname + ':*') ||
@@ -83,7 +86,7 @@ Server.prototype.checkRequest = function(req, fn) {
/**
* Sets/gets whether client code is being served.
*
* @param {Boolean} whether to serve client code
* @param {Boolean} v whether to serve client code
* @return {Server|Boolean} self when setting or value when getting
* @api public
*/
@@ -106,7 +109,7 @@ var oldSettings = {
};
/**
* Backwards compatiblity.
* Backwards compatibility.
*
* @api public
*/
@@ -136,7 +139,7 @@ Server.prototype.set = function(key, val){
/**
* Sets the client serving path.
*
* @param {String} pathname
* @param {String} v pathname
* @return {Server|String} self when setting or value when getting
* @api public
*/
@@ -150,7 +153,7 @@ Server.prototype.path = function(v){
/**
* Sets the adapter for rooms.
*
* @param {Adapter} pathname
* @param {Adapter} v pathname
* @return {Server|Adapter} self when setting or value when getting
* @api public
*/
@@ -159,7 +162,9 @@ Server.prototype.adapter = function(v){
if (!arguments.length) return this._adapter;
this._adapter = v;
for (var i in this.nsps) {
this.nsps[i].initAdapter();
if (this.nsps.hasOwnProperty(i)) {
this.nsps[i].initAdapter();
}
}
return this;
};
@@ -167,7 +172,7 @@ Server.prototype.adapter = function(v){
/**
* Sets the allowed origins for requests.
*
* @param {String} origins
* @param {String} v origins
* @return {Server|Adapter} self when setting or value when getting
* @api public
*/
@@ -191,7 +196,7 @@ Server.prototype.origins = function(v){
Server.prototype.listen =
Server.prototype.attach = function(srv, opts){
if ('function' == typeof srv) {
var msg = 'You are trying to attach socket.io to an express' +
var msg = 'You are trying to attach socket.io to an express ' +
'request handler function. Please pass a http.Server instance.';
throw new Error(msg);
}
@@ -209,13 +214,14 @@ Server.prototype.attach = function(srv, opts){
res.end();
});
srv.listen(port);
}
// set engine.io path to `/socket.io`
opts = opts || {};
opts.path = opts.path || '/socket.io';
opts.path = opts.path || this.path();
// set origins verification
opts.allowRequest = this.checkRequest.bind(this);
opts.allowRequest = opts.allowRequest || this.checkRequest.bind(this);
// initialize engine
debug('creating engine.io instance with opts %j', opts);
@@ -224,6 +230,9 @@ Server.prototype.attach = function(srv, opts){
// attach static file serving
if (this._serveClient) this.attachServe(srv);
// Export http server
this.httpServer = srv;
// bind to engine events
this.bind(this.eio);
@@ -233,7 +242,7 @@ Server.prototype.attach = function(srv, opts){
/**
* Attaches the static file serving.
*
* @param {Function|http.Server} http server
* @param {Function|http.Server} srv http server
* @api private
*/
@@ -244,7 +253,7 @@ Server.prototype.attachServe = function(srv){
var self = this;
srv.removeAllListeners('request');
srv.on('request', function(req, res) {
if (0 == req.url.indexOf(url)) {
if (0 === req.url.indexOf(url)) {
self.serve(req, res);
} else {
for (var i = 0; i < evs.length; i++) {
@@ -263,8 +272,9 @@ Server.prototype.attachServe = function(srv){
*/
Server.prototype.serve = function(req, res){
if (req.headers.etag) {
if (clientVersion == req.headers.etag) {
var etag = req.headers['if-none-match'];
if (etag) {
if (clientVersion == etag) {
debug('serve client 304');
res.writeHead(304);
res.end();
@@ -282,7 +292,7 @@ Server.prototype.serve = function(req, res){
/**
* Binds socket.io to an engine.io instance.
*
* @param {engine.Server} engine.io (or compatible) server
* @param {engine.Server} engine engine.io (or compatible) server
* @return {Server} self
* @api public
*/
@@ -296,7 +306,7 @@ Server.prototype.bind = function(engine){
/**
* Called with each incoming transport connection.
*
* @param {engine.Socket} socket
* @param {engine.Socket} conn
* @return {Server} self
* @api public
*/
@@ -311,26 +321,49 @@ Server.prototype.onconnection = function(conn){
/**
* Looks up a namespace.
*
* @param {String} nsp name
* @param {Function} optional, nsp `connection` ev handler
* @param {String} name nsp name
* @param {Function} [fn] optional, nsp `connection` ev handler
* @api public
*/
Server.prototype.of = function(name, fn){
if (!this.nsps[name]) {
if (String(name)[0] !== '/') name = '/' + name;
var nsp = this.nsps[name];
if (!nsp) {
debug('initializing namespace %s', name);
var nsp = new Namespace(this, name);
nsp = new Namespace(this, name);
this.nsps[name] = nsp;
}
if (fn) this.nsps[name].on('connect', fn);
return this.nsps[name];
if (fn) nsp.on('connect', fn);
return nsp;
};
/**
* Closes server connection
*
* @api public
*/
Server.prototype.close = function(){
for (var id in this.nsps['/'].sockets) {
if (this.nsps['/'].sockets.hasOwnProperty(id)) {
this.nsps['/'].sockets[id].onclose();
}
}
this.engine.close();
if(this.httpServer){
this.httpServer.close();
}
};
/**
* Expose main namespace (/).
*/
['on', 'to', 'in', 'use', 'emit', 'send', 'write'].forEach(function(fn){
['on', 'to', 'in', 'use', 'emit', 'send', 'write', 'clients', 'compress'].forEach(function(fn){
Server.prototype[fn] = function(){
var nsp = this.sockets[fn];
return nsp.apply(this.sockets, arguments);
@@ -338,8 +371,9 @@ Server.prototype.of = function(name, fn){
});
Namespace.flags.forEach(function(flag){
Server.prototype.__defineGetter__(flag, function(name){
this.flags.push(name);
Server.prototype.__defineGetter__(flag, function(){
this.sockets.flags = this.sockets.flags || {};
this.sockets.flags[flag] = true;
return this;
});
});

View File

@@ -7,7 +7,7 @@ var Socket = require('./socket');
var Emitter = require('events').EventEmitter;
var parser = require('socket.io-parser');
var debug = require('debug')('socket.io:namespace');
var hasBin = require('has-binary-data');
var hasBin = require('has-binary');
/**
* Module exports.
@@ -29,7 +29,10 @@ exports.events = [
* Flags.
*/
exports.flags = ['json'];
exports.flags = [
'json',
'volatile'
];
/**
* `EventEmitter#emit` reference.
@@ -48,11 +51,10 @@ var emit = Emitter.prototype.emit;
function Namespace(server, name){
this.name = name;
this.server = server;
this.sockets = [];
this.sockets = {};
this.connected = {};
this.fns = [];
this.ids = 0;
this.acks = {};
this.initAdapter();
}
@@ -102,7 +104,7 @@ Namespace.prototype.use = function(fn){
* Executes the middleware for an incoming client.
*
* @param {Socket} socket that will get added
* @param {Function} last fn call in the middleware
* @param {Function} fn last fn call in the middleware
* @api private
*/
@@ -148,9 +150,9 @@ Namespace.prototype['in'] = function(name){
* @api private
*/
Namespace.prototype.add = function(client, fn){
Namespace.prototype.add = function(client, query, fn){
debug('adding socket to nsp %s', this.name);
var socket = new Socket(this, client);
var socket = new Socket(this, client, query);
var self = this;
this.run(socket, function(err){
process.nextTick(function(){
@@ -158,7 +160,7 @@ Namespace.prototype.add = function(client, fn){
if (err) return socket.error(err.data || err.message);
// track socket
self.sockets.push(socket);
self.sockets[socket.id] = socket;
// it's paramount that the internal `onconnect` logic
// fires before user-set events to prevent state order
@@ -185,9 +187,8 @@ Namespace.prototype.add = function(client, fn){
*/
Namespace.prototype.remove = function(socket){
var i = this.sockets.indexOf(socket);
if (~i) {
this.sockets.splice(i, 1);
if (this.sockets.hasOwnProperty(socket.id)) {
delete this.sockets[socket.id];
} else {
debug('ignoring remove for %s', socket.id);
}
@@ -240,3 +241,32 @@ Namespace.prototype.write = function(){
this.emit.apply(this, args);
return this;
};
/**
* Gets a list of clients.
*
* @return {Namespace} self
* @api public
*/
Namespace.prototype.clients = function(fn){
this.adapter.clients(this.rooms, fn);
// delete rooms flag for scenario:
// .in('room').clients() (GH-1978)
delete this.rooms;
return this;
};
/**
* Sets the compress flag.
*
* @param {Boolean} compress if `true`, compresses the sending data
* @return {Socket} self
* @api public
*/
Namespace.prototype.compress = function(compress){
this.flags = this.flags || {};
this.flags.compress = compress;
return this;
};

View File

@@ -7,7 +7,7 @@ var Emitter = require('events').EventEmitter;
var parser = require('socket.io-parser');
var url = require('url');
var debug = require('debug')('socket.io:socket');
var hasBin = require('has-binary-data');
var hasBin = require('has-binary');
/**
* Module exports.
@@ -25,7 +25,9 @@ exports.events = [
'error',
'connect',
'disconnect',
'newListener'
'disconnecting',
'newListener',
'removeListener'
];
/**
@@ -54,19 +56,18 @@ var emit = Emitter.prototype.emit;
* @api public
*/
function Socket(nsp, client){
function Socket(nsp, client, query){
this.nsp = nsp;
this.server = nsp.server;
this.adapter = this.nsp.adapter;
this.id = client.id;
this.request = client.request;
this.id = nsp.name !== '/' ? nsp.name + '#' + client.id : client.id;
this.client = client;
this.conn = client.conn;
this.rooms = [];
this.rooms = {};
this.acks = {};
this.connected = true;
this.disconnected = false;
this.handshake = this.buildHandshake();
this.handshake = this.buildHandshake(query);
}
/**
@@ -88,7 +89,7 @@ flags.forEach(function(flag){
});
/**
* `request` engine.io shorcut.
* `request` engine.io shortcut.
*
* @api public
*/
@@ -103,16 +104,28 @@ Socket.prototype.__defineGetter__('request', function(){
* @api private
*/
Socket.prototype.buildHandshake = function(){
Socket.prototype.buildHandshake = function(query){
var self = this;
function buildQuery(){
var requestQuery = url.parse(self.request.url, true).query;
//if socket-specific query exist, replace query strings in requestQuery
if(query){
query.t = requestQuery.t;
query.EIO = requestQuery.EIO;
query.transport = requestQuery.transport;
return query;
}
return requestQuery || {};
}
return {
headers: this.request.headers,
time: (new Date) + '',
address: this.request.connection.address(),
address: this.conn.remoteAddress,
xdomain: !!this.request.headers.origin,
secure: !!this.request.connection.encrypted,
issued: +(new Date),
url: this.request.url,
query: url.parse(this.request.url, true).query || {}
query: buildQuery()
};
};
@@ -131,10 +144,11 @@ Socket.prototype.emit = function(ev){
var packet = {};
packet.type = hasBin(args) ? parser.BINARY_EVENT : parser.EVENT;
packet.data = args;
var flags = this.flags || {};
// access last argument to see if it's an ACK callback
if ('function' == typeof args[args.length - 1]) {
if (this._rooms || (this.flags && this.flags.broadcast)) {
if (this._rooms || flags.broadcast) {
throw new Error('Callbacks are not supported when broadcasting');
}
@@ -143,15 +157,18 @@ Socket.prototype.emit = function(ev){
packet.id = this.nsp.ids++;
}
if (this._rooms || (this.flags && this.flags.broadcast)) {
if (this._rooms || flags.broadcast) {
this.adapter.broadcast(packet, {
except: [this.id],
rooms: this._rooms,
flags: this.flags
flags: flags
});
} else {
// dispatch packet
this.packet(packet);
this.packet(packet, {
volatile: flags.volatile,
compress: flags.compress
});
}
// reset flags
@@ -195,20 +212,22 @@ Socket.prototype.write = function(){
* Writes a packet.
*
* @param {Object} packet object
* @param {Object} opts options
* @api private
*/
Socket.prototype.packet = function(packet, preEncoded){
Socket.prototype.packet = function(packet, opts){
packet.nsp = this.nsp.name;
var volatile = this.flags && this.flags.volatile;
this.client.packet(packet, preEncoded, volatile);
opts = opts || {};
opts.compress = false !== opts.compress;
this.client.packet(packet, opts);
};
/**
* Joins a room.
*
* @param {String} room
* @param {Function} optional, callback
* @param {Function} fn optional, callback
* @return {Socket} self
* @api private
*/
@@ -216,11 +235,14 @@ Socket.prototype.packet = function(packet, preEncoded){
Socket.prototype.join = function(room, fn){
debug('joining room %s', room);
var self = this;
if (~this.rooms.indexOf(room)) return this;
if (this.rooms.hasOwnProperty(room)) {
fn && fn(null);
return this;
}
this.adapter.add(this.id, room, function(err){
if (err) return fn && fn(err);
debug('joined room %s', room);
self.rooms.push(room);
self.rooms[room] = room;
fn && fn(null);
});
return this;
@@ -230,7 +252,7 @@ Socket.prototype.join = function(room, fn){
* Leaves a room.
*
* @param {String} room
* @param {Function} optional, callback
* @param {Function} fn optional, callback
* @return {Socket} self
* @api private
*/
@@ -241,7 +263,7 @@ Socket.prototype.leave = function(room, fn){
this.adapter.del(this.id, room, function(err){
if (err) return fn && fn(err);
debug('left room %s', room);
self.rooms.splice(self.rooms.indexOf(room, 1));
delete self.rooms[room];
fn && fn(null);
});
return this;
@@ -255,10 +277,11 @@ Socket.prototype.leave = function(room, fn){
Socket.prototype.leaveAll = function(){
this.adapter.delAll(this.id);
this.rooms = {};
};
/**
* Called by `Namespace` upon succesful
* Called by `Namespace` upon successful
* middleware execution (ie: authorization).
*
* @api private
@@ -266,9 +289,9 @@ Socket.prototype.leaveAll = function(){
Socket.prototype.onconnect = function(){
debug('socket connected - writing packet');
this.nsp.connected[this.id] = this;
this.join(this.id);
this.packet({ type: parser.CONNECT });
this.nsp.connected[this.id] = this;
};
/**
@@ -293,6 +316,10 @@ Socket.prototype.onpacket = function(packet){
this.onack(packet);
break;
case parser.BINARY_ACK:
this.onack(packet);
break;
case parser.DISCONNECT:
this.ondisconnect();
break;
@@ -324,7 +351,7 @@ Socket.prototype.onevent = function(packet){
/**
* Produces an ack callback to emit with an event.
*
* @param {Number} packet id
* @param {Number} id packet id
* @api private
*/
@@ -336,11 +363,15 @@ Socket.prototype.ack = function(id){
if (sent) return;
var args = Array.prototype.slice.call(arguments);
debug('sending ack %j', args);
var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK;
self.packet({
id: id,
type: parser.ACK,
type: type,
data: args
});
sent = true;
};
};
@@ -372,16 +403,33 @@ Socket.prototype.ondisconnect = function(){
this.onclose('client namespace disconnect');
};
/**
* Handles a client error.
*
* @api private
*/
Socket.prototype.onerror = function(err){
if (this.listeners('error').length) {
this.emit('error', err);
} else {
console.error('Missing error handler on `socket`.');
console.error(err.stack);
}
};
/**
* Called upon closing. Called by `Client`.
*
* @param {String} reason
* @throw {Error} optional error object
* @api private
*/
Socket.prototype.onclose = function(reason){
if (!this.connected) return this;
debug('closing socket - reason %s', reason);
this.emit('disconnecting', reason);
this.leaveAll();
this.nsp.remove(this);
this.client.remove(this);
@@ -394,7 +442,7 @@ Socket.prototype.onclose = function(reason){
/**
* Produces an `error` packet.
*
* @param {Object} error object
* @param {Object} err error object
* @api private
*/
@@ -405,7 +453,7 @@ Socket.prototype.error = function(err){
/**
* Disconnects this client.
*
* @param {Boolean} if `true`, closes the underlying connection
* @param {Boolean} close if `true`, closes the underlying connection
* @return {Socket} self
* @api public
*/
@@ -420,3 +468,17 @@ Socket.prototype.disconnect = function(close){
}
return this;
};
/**
* Sets the compress flag.
*
* @param {Boolean} compress if `true`, compresses the sending data
* @return {Socket} self
* @api public
*/
Socket.prototype.compress = function(compress){
this.flags = this.flags || {};
this.flags.compress = compress;
return this;
};

View File

@@ -1,6 +1,6 @@
{
"name": "socket.io",
"version": "1.0.1",
"version": "1.5.1",
"description": "node.js realtime framework server",
"keywords": [
"realtime",
@@ -11,27 +11,39 @@
"socket",
"io"
],
"main": "./lib/index",
"files": [
"lib/"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/LearnBoost/socket.io"
"url": "git://github.com/socketio/socket.io"
},
"scripts": {
"test": "make test"
"test": "gulp test"
},
"dependencies": {
"engine.io": "1.2.1",
"socket.io-parser": "2.1.4",
"socket.io-client": "1.0.1",
"socket.io-adapter": "0.2.0",
"has-binary-data": "0.1.1",
"debug": "0.7.4"
"engine.io": "1.7.2",
"socket.io-parser": "2.3.1",
"socket.io-client": "1.5.1",
"socket.io-adapter": "0.4.0",
"has-binary": "0.1.7",
"debug": "2.2.0"
},
"devDependencies": {
"mocha": "1.16.2",
"babel-preset-es2015": "6.3.13",
"del": "2.2.0",
"expect.js": "0.3.1",
"supertest": "0.8.2",
"superagent": "0.17.0",
"istanbul": "0.2.3"
"gulp": "3.9.0",
"gulp-babel": "6.1.1",
"gulp-istanbul": "0.10.3",
"gulp-mocha": "2.2.0",
"gulp-task-listing": "1.0.1",
"istanbul": "0.4.1",
"mocha": "2.3.4",
"superagent": "1.6.1",
"supertest": "1.1.0"
},
"contributors": [
{

BIN
test/fixtures/big.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

174066
test/fixtures/big.json vendored Normal file

File diff suppressed because it is too large Load Diff

11
test/fixtures/server-close.js vendored Normal file
View File

@@ -0,0 +1,11 @@
var server = require('http').createServer();
var ioc = require('socket.io-client');
var io = require('../..')(server);
var srv = server.listen(function() {
var socket = ioc('ws://localhost:' + server.address().port);
socket.on('connect', function() {
io.close();
socket.close();
});
});

File diff suppressed because it is too large Load Diff