-
-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
3 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d9cdebd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不能简单的注释掉这段代码,这段代码的作用是校验请求数据是否完整的。
如果仅仅是为了支持中文的话可以修改成下面的样子:
d9cdebd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,只有在降级到
polling
的时候才会走到这个逻辑,websocket
不会走到这里,所以这里的更改不会影响基于websocket
通讯。polling
的时候能保证每次发送的是单独的一个完整的包,不会多个请求拼接在一起的情况(不过不清楚socket.io客户端是否有其它设置允许多个包拼接一起发送给服务端),所以不会有问题。对,原来bug是用
substr
截取后json不完整,因为客户端认为一个中文长度是1,但是substr
认为是3,导致发中文时服务端无法解析。看起来用mb_substr是个稳妥的方案,
但是客户端传来的中文是utf8.js转换过的中文,
还得测试下
mb_substr
是否能真的截取出完整的json数据(完整的请求数据)来,如果截取的不是一个完整的json那么会有问题。