如何在apache服务器上运行socket.io(仅客户端) [英] How to run socket.io (client side only) on apache server
问题描述
我想在我的apache服务器上运行socket.io的客户端。
I want to run client side of socket.io on my apache server.
我已将socket.io目录上传到我的web服务器并试用了简单的客户端来自主站点 socket.io 的连接示例,但它无法正常工作。我不知道我需要什么来使它工作并连接我正在运行的服务器。
I have uploaded the socket.io directory to my web server and tried the simple client connection example from the main site socket.io but its not working. I dont know what do I need to get it work and connect my running server.
我希望,我已经清楚地解释了我的问题。
I Hope, I have clearly explained my problem.
谢谢。
推荐答案
复制 socket.io中的所有文件\\ nnode_modules\socket.io-client\dist
到你的apache服务器,例如 js
文件夹。然后将 socket.io.min.js
添加到您的页面。
Copy all the files in socket.io\node_modules\socket.io-client\dist
to your apache server for example to the js
folder. Then add the socket.io.min.js
to your page.
<script src="js/socket.io.min.js" type="text/javascript"></script>
<script type="text/javascript">
var socket = io.connect('http://localhost:3000');
socket.on('news', function (data) {
console.log(data);
});
</script>
这篇关于如何在apache服务器上运行socket.io(仅客户端)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!