头痛= =。。 本来已经实现了nodejs做server和client用socketio通信 。。。
然后老师要求用phantomjs运行server。。。:“写一个socket server的js文件用phantomjs运行就行”
然后我
1.我用phantomjs直接运行nodejs的server:
报错:Error: Cannot find module 'events'
phantomjs://platform/bootstrap.js:299 in require
phantomjs://platform/bootstrap.js:263 in require
phantomjs://platform/express.js:6
Error: Cannot find module 'http'
phantomjs://platform/bootstrap.js:299 in require
phantomjs://platform/bootstrap.js:263 in require
phantomjs://platform/index.js:7
TypeError: Object is not a constructor (evaluating 'express()')
2.没用socketio 直接用socket
var socket = new WebSocket(“url”)
socket.onopen = function(event) {...................}
又和之前的client链接不上。。。
报错:Failed to load resource: net::ERR_CONNECTION_REFUSED
下面贴一下我的代码 server是index2.js client是index.html
瞎写的一个websocket是index3.js

。。就算第三个连上了,有自定义事件吗?。。。
求大佬告知一下解决方法 - - 。。另外我也查过用phantomjs直接建webserver。。。但是那个的socket好像不是很好用
求大佬告知如何是好。。。。本人愚钝