草庐IT

ws-client

全部标签

node.js - Node js - Socket.io-client 未连接到 socket.io 服务器

我正在尝试使用以下代码连接到socket.io-client:服务器://Loadrequirementsvarhttp=require('http'),io=require('socket.io');//Createserver&socketvarserver=http.createServer(function(req,res){//SendHTMLheadersandmessageres.writeHead(404,{'Content-Type':'text/html'});res.end('Aw,snap!404');});server.listen(8080);io=io.l

node.js - Node js - Socket.io-client 未连接到 socket.io 服务器

我正在尝试使用以下代码连接到socket.io-client:服务器://Loadrequirementsvarhttp=require('http'),io=require('socket.io');//Createserver&socketvarserver=http.createServer(function(req,res){//SendHTMLheadersandmessageres.writeHead(404,{'Content-Type':'text/html'});res.end('Aw,snap!404');});server.listen(8080);io=io.l

node.js - 错误 : Cannot find module 'npm-registry-client'

每当我尝试安装npm-registry-client时,都会收到错误“错误:找不到模块'npm-registry-client'”。我已尝试使用以下命令解决此问题,但这不起作用:npm卸载npminstall-gnpm@latest完整的输出是:user@pc~/devel>npminstallnpm-registry-client--savemodule.js:340throwerr;^Error:Cannotfindmodule'npm-registry-client'atFunction.Module._resolveFilename(module.js:338:15)atFun

node.js - 错误 : Cannot find module 'npm-registry-client'

每当我尝试安装npm-registry-client时,都会收到错误“错误:找不到模块'npm-registry-client'”。我已尝试使用以下命令解决此问题,但这不起作用:npm卸载npminstall-gnpm@latest完整的输出是:user@pc~/devel>npminstallnpm-registry-client--savemodule.js:340throwerr;^Error:Cannotfindmodule'npm-registry-client'atFunction.Module._resolveFilename(module.js:338:15)atFun

Node.js socket.io-client connect_failed/connect_error 事件

我在玩node.js和socket.io-client。我正在尝试连接到不存在的channel以触发事件“connect_failed”(在https://github.com/LearnBoost/socket.io-client中指定)。但是我无法让事件正常进行:varclientio=require('socket.io-client');console.log('Tryingstuff...');//thechanneldoesnotexistvarsocket=clientio.connect('http://localhost:4000/news');//Iexpectth

Node.js socket.io-client connect_failed/connect_error 事件

我在玩node.js和socket.io-client。我正在尝试连接到不存在的channel以触发事件“connect_failed”(在https://github.com/LearnBoost/socket.io-client中指定)。但是我无法让事件正常进行:varclientio=require('socket.io-client');console.log('Tryingstuff...');//thechanneldoesnotexistvarsocket=clientio.connect('http://localhost:4000/news');//Iexpectth

javascript - Socket IO 房间 : Get list of clients in specific room

我正在尝试显示特定房间中的客户列表。我只想显示他们的用户名,而不是他们的套接字ID。我现在的位置:socket.set('nickname',"Earl");socket.join('chatroom1');console.log('Userjoinedchatroom1);varroster=io.sockets.clients('chatroom1');for(iinroster){console.log('Username:'+roster[i]);}没有任何运气让它列出套接字ID或任何东西。但是希望它返回昵称。 最佳答案 在

javascript - Socket IO 房间 : Get list of clients in specific room

我正在尝试显示特定房间中的客户列表。我只想显示他们的用户名,而不是他们的套接字ID。我现在的位置:socket.set('nickname',"Earl");socket.join('chatroom1');console.log('Userjoinedchatroom1);varroster=io.sockets.clients('chatroom1');for(iinroster){console.log('Username:'+roster[i]);}没有任何运气让它列出套接字ID或任何东西。但是希望它返回昵称。 最佳答案 在

javascript - 带有 Express : Importing client-side javascript using script tags in Jade views? 的 Node.js

我有一个使用Jade模板引擎运行的node.jsexpress服务器。我有一个布局文件,它可以像这样导入单个View的主体:!!!htmlheadtitle=title||'Titlenotset.'body#headerh1Header.#content!=body//-thisrendersthebodyofanindividualview#footerpFooter.例如以下索引页面:pWelcometothefrontpage.pThispageservesasanow.jstest.这很好用。但是,我现在想包含两个专门用于该索引页面的客户端javascript库(因此不是每个

javascript - 带有 Express : Importing client-side javascript using script tags in Jade views? 的 Node.js

我有一个使用Jade模板引擎运行的node.jsexpress服务器。我有一个布局文件,它可以像这样导入单个View的主体:!!!htmlheadtitle=title||'Titlenotset.'body#headerh1Header.#content!=body//-thisrendersthebodyofanindividualview#footerpFooter.例如以下索引页面:pWelcometothefrontpage.pThispageservesasanow.jstest.这很好用。但是,我现在想包含两个专门用于该索引页面的客户端javascript库(因此不是每个