在Ubuntu上运行echo服务器

时间:2012-06-15 10:10:46

标签: node.js ubuntu websocket

我按照本教程在ubuntu上安装node.js,安装成功。但是当我输入节点echo-server.js时,我收到以下错误:

module.js:340  
    throw err;  
      ^ 
Error: Cannot find module '../../lib/ws/server'  
    at Function.Module._resolveFilename (module.js:338:15)    
    at Function.Module._load (module.js:280:25)  
    at Module.require (module.js:362:17)  
    at require (module.js:378:17)  
    at Object.<anonymous> (/home/jci/node/joyent-node-283d735/echo-server.js:2:10)  
    at Module._compile (module.js:449:26)  
    at Object.Module._extensions..js (module.js:467:10)  
   at Module.load (module.js:356:32)  
   at Function.Module._load (module.js:312:12)  
   at Module.runMain (module.js:487:10)  

回显服务器代码:

 var sys = require("util")  
  , ws = require('../../lib/ws/server');  

var server = ws.createServer({debug: true});  

 // Handle WebSocket Requests  
 server.addListener("connection", function(conn){  
  conn.send("Connection: "+conn.id);  

   conn.addListener("message", function(message){  
    conn.send("<"+conn.id+"> "+message);  

    if(message == "error"){  
      conn.emit("error", "test");  
}

}); });

server.addListener(“error”,function(){   console.log(Array.prototype.join.call(arguments,“,”)); });

server.addListener(“disconnected”,function(conn){   server.broadcast(“&lt;”+ conn.id +“&gt; disconnected”); });

server.listen(8000);

但缺少lib / ws / server。但是我从哪里得到它? 我猜我的node.js安装中没有Web套接字服务器。

感谢
斯纳

0 个答案:

没有答案