Tag: 页面刷新

刷新/重新加载socket.io“连接”事件不会触发

今天有socket.io的问题。 当我刷新页面.on(“connect”,{})永远不会触发。 当我从url中加载一个页面时,所有的事件都应该如此。 正如你可以看到下面我设置gameStatus破碎。 在一系列客户/服务器通信之后,游戏状态应该更新为“就绪”,并且应该在服务器上创build新的玩家。 当我重新加载页面(cmd + r)时,没有客户端事件触发。 服务器端识别新的连接“看到”新的socket.id并发出“发送空间”事件,但事件在客户端没有收到。 我试图强制新的连接,但我不知道我是否正确使用。 上周这工作正如我所料,然后今天甚至没有更新的代码,它不能让页面刷新触发这些事件。 一切正常,如果我从完整的url( http://localhost:3000在这种情况下)加载页面, index.html的: var io = io.connect('/', {'force new connection': true}); client.js var gameStatus = 'broken'; var localPlayer; window.onload = function() { console.log(gameStatus); // "broken" io.on("connect", onSocketConnected); io.on("disconnect", onSocketDisconnect); io.on("new player", onNewPlayer); io.on("send room", function(data){ console.log("send room fired"); // doesn't fire on refresh addPlayer(data); […]

用Angular,Express和Jade刷新特定页面(使用html5mode)

我试图刷新一个页面,并执行客户端路由在ng-view中打开一个模板 Index.jade extends layouts/default block content section(data-ng-view) script(type="text/javascript"). window.user = !{user}; default.jade doctype html html(lang='en', xmlns='http://www.w3.org/1999/xhtml', xmlns:fb='https://www.facebook.com/2008/fbml', itemscope='itemscope', itemtype='http://schema.org/Product') include ../includes/head body div(data-ng-include="'static/modules/core/views/core.header.view.html'", data-role="navigation") div(data-ng-include="'static/modules/core/views/core.index.view.html'", data-role="navigation") div(data-ng-include="'static/modules/core/views/core.menu.view.html'", data-role="navigation") div(data-ng-include="'static/modules/core/views/core.footer.view.html'", data-role="navigation") include ../includes/foot 服务器路由 // Camera Routes app.get('/api/cameras', cameras.all); app.post('/api/cameras', auth.requiresLogin, cameras.create); app.get('/api/cameras/:cameraId', cameras.show); app.put('/api/cameras/:cameraId', auth.requiresLogin, auth.article.hasAuthorization, cameras.update); app.del('/api/cameras/:cameraId', auth.requiresLogin, auth.article.hasAuthorization, cameras.destroy); app.param('cameraId', cameras.camera); // Home […]