在ubuntu上安装并运行browserquest

Ers*_*ker 5 javascript httpserver node.js

我已经安装了node.js和必要的包来运行browserquest.我已经启动了在端口8080上运行的browserquest服务器,当我进入浏览器并键入http:// localhost:8080/status时,我可以看到服务器正在运行,并且当前没有连接客户端.我在client/config/build_config.json文件中使用这样的配置构建客户端

{
   "host": "http://127.0.0.1",
   "port": 8080
}
Run Code Online (Sandbox Code Playgroud)

我在bin/build.sh中构建我的客户端.然后我运行此命令来创建http-server来提供客户端文件.

http-server path-to-client-build -p 8000
Run Code Online (Sandbox Code Playgroud)

我可以通过转到http:// localhost:8000/index.html来查看运行httpserver的索引页面,但是当我尝试连接时,在连接到服务器后它会卡住.

注意:我使用此http服务器来托管客户端文件http://search.npmjs.org/#/http-server

Ers*_*ker 6

我认为客户端构建在github上的当前版本中存在一些问题.相反,我使用了实际的客户端文件夹.我已按照这些步骤使其工作.

确保已安装node和npm.

1)从github repo获取副本.

git clone https://github.com/mozilla/BrowserQuest.git
Run Code Online (Sandbox Code Playgroud)

2)为服务器安装所需的节点包

npm install underscore log bison websocket websocket-server sanitizer memcache
Run Code Online (Sandbox Code Playgroud)

3)启动服务器

node server/js/main.js
Run Code Online (Sandbox Code Playgroud)

4)转到客户端目录并安装http-server模块以服务客户端文件

cd client
npm install -g http-server
Run Code Online (Sandbox Code Playgroud)

5)编辑config_build.json-dist指向你的主机ip和端口(在我的情况下是127.0.0.1 localhost)

{
"host": "127.0.0.1",
"port": 8000,
"dispatcher": false
}
Run Code Online (Sandbox Code Playgroud)

6)将编辑过的config_build.json-dist复制到2个新文件中

cp config_build.json-dist config_build.json
cp config_build.json-dist config_local.json
Run Code Online (Sandbox Code Playgroud)

7)将共享文件夹复制到客户端文件夹

cp -r ../shared .
Run Code Online (Sandbox Code Playgroud)

8)启动http-server来提供客户端文件

http-server
Run Code Online (Sandbox Code Playgroud)

并且您的服务器和客户端应该正在运行.您可以通过转到http:// ipaddress:port/status来检查服务器是否正在运行,该应显示已连接客户端的数组.如果没有空数组.并且您的客户端应该在http:// ipaddress:8000/index.html上运行

基于dirkk0的教程 https://gist.github.com/2275361