Socket.io客户端请求源URL
在客户端,在浏览器中,我有这样的代码:
this.socket.on('initial', function(data) { console.log(data); });
在服务器上我有:
socket.sockets.on('connection', function(client){ console.log('client connected'); });
我的问题是:如何检测请求来自哪里的URL? 例如,如果第一个闭包在“/ posts / view / 1”上运行,我希望能够在第二个闭包内部检测到它。
您可以将这些数据发送回服务器。 对细节有点手摇,但是怎么样:
在客户端:
this.socket.on('initial', function(data) { // do whatever with data var my_location = get_page_location_with_javascript(); // or whatever this.socket.emit('phone_home', my_location); });
在服务器上:
this.sockets.on('phone_home', function(url) { console.log("The URL was " + url); });
- 使用Socket.io与Node.js,Express和Jade
- Node.js:如何刷新套接字?
- 在io.sockets.on()之外的socket.send
- 如何从NodeJs中的tcp套接字断开连接
- UDP多播广播节点
- MongoLab上的Node.js和MongoDB:每个插入上的“套接字closures”
- koush AndroidAsync Socket.IO:看起来ConnectCallback()在Google Glass上没有被触发
- Express / torrent-stream:从stream中写入文件,使用url将套接字发送给客户端,但客户端无法find文件
- 节点套接字挂起http错误