简体   繁体   English

每次发送请求时检索轮询URL - Socket.io

[英]Retrieve polling URL each time a request is sent - Socket.io

I am currently looking to see if I can pick up the URL which is used in polling via socket.io EG 我目前正在查看是否可以通过socket.io EG获取轮询中使用的URL

http://127.0.0.1:8000/socket.io/?EIO=3&transport=polling&t=MSTH-j0&sid=bycdflRlaXRivG9MAACx http://127.0.0.1:8000/socket.io/?EIO=3&transport=polling&t=MSTH-j0&sid=bycdflRlaXRivG9MAACx

The reason for this is am going to do an override with that URL. 这样做的原因是我将使用该URL进行覆盖。 Is there anything in socket that would return me this value each time I send through a request via polling. 套接字中有什么东西可以在每次通过轮询发送请求时返回此值。

Can I return this value somehow as is or am I going to have to construct it manually via 我可以按原样以某种方式返回此值,或者我将不得不通过手动构建它

socket.on('ping', function () {
    console.log('ping');
    console.log(socket);
});

I found the answer - I was able to get the url I was polling via: 我找到了答案 - 我能够获得我通过以下方式查询的网址:

socket.on('ping', function () {
    console.log('ping');
    console.log(socket.io.engine.transport.pollXhr.uri);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM