Mar*_*lon 6 php connection websocket
我已经使用开发了客户端 - 服务器连接socket.io
,我很高兴地说它完美无缺.问题来了,因为我需要从php Source创建该连接(而不是"echo html javascript").有点像
$socket = socket.createConectionJS;
Run Code Online (Sandbox Code Playgroud)
我尝试过不同的方法,例如:
我认为解决它的唯一方法是通过创建套接字来模拟Web套接字连接,方法与de socket.io类相同,但在php中
Anny socket.io专家可以帮忙吗?
Tnks!!_
是的,当时我很快就开始了。我很幸运,已经用 PHP 构建了一个相当先进的网页抓取库,因此我只需将 TamperData(firefox 插件)中的 XML 插入其中,并调整一些内容。
模拟 xhr-polling(我的代理不允许 websockets,无论如何这看起来更简单)...
提出请求:
/socket.io/1/?t=1337779479761
Run Code Online (Sandbox Code Playgroud)
(13377...数字只是一个时间戳,使用 time() 生成它)。
这应该返回类似这样的内容:
682970926640665221:60:60:websocket,htmlfile,xhr-polling,jsonp-polling
Run Code Online (Sandbox Code Playgroud)
抓住前面的大数字,这就是您的“[CONNECT_ID]”,您将在会话的剩余时间内保留它。现在做另一个请求:
/socket.io/1/xhr-polling/[CONNECT_ID]?t=[TIMESTAMP]
Run Code Online (Sandbox Code Playgroud)
你会得到类似 ::1 的结果
据我所知,这一切看起来都很基本……没有特殊的标题或任何偷偷摸摸的东西。建议您使用 TamperData 或数据包嗅探器,然后自行执行即可。这是我的代码的输出:
$ php RealTestCurl.php xml/xhr.xml init1 xhr1 xhr1 xhr1 xhr1
xmlFilename: xml/xhr.xml
Step: init1
Reply: 7638339571841585529:60:60:websocket,htmlfile,xhr-polling,jsonp-polling
Found: connect_id: ([0-9]*) - 7638339571841585529
Step: xhr1
Reply: 1::
Step: xhr1
Reply: ?46?5:::{"name":"news","args":[{"hello":"world"}]}?63?5:::{"name":"this","args":[{"will":"be received by everyone"}]}
Step: xhr1
.... there is a massive 20 second timeout here
Step: xhr1
8::
Step: xhr1
8::
Run Code Online (Sandbox Code Playgroud)
在 node.js/socket.io 方面,运行其首页的基本示例:
debug - client authorized
info - handshake authorized 3445861131360107212
debug - setting request GET /socket.io/1/xhr-polling/3445861131360107212?t=1337781185
debug - setting poll timeout
debug - client authorized for
debug - clearing poll timeout
debug - xhr-polling writing 1::
debug - set close timeout for client 3445861131360107212
debug - websocket writing 5:::{"name":"this","args":[{"will":"be received by everyone"}]}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12644 次 |
最近记录: |