此代码有什么问题?当我尝试与客户端连接时,没有任何反应,我正在使用简单Web套接字客户端扩展。使用 websocket.io 一切都很好。
import * as express from 'express';
import * as http from 'http';
import * as io from 'socket.io';
export class AppClass{
private _port:number=3080;
constructor(){
const expressServer = express();
const server = http.createServer(expressServer);
let webSocket:io.Server = io(server);
webSocket.on('connection',
(s:io.Socket)=>{
console.log('socket.io connection...', s);
s.on('message',
(msg:string)=>{
console.log(msg);
})
}
);
server.listen(
this._port,
()=>{
console.log('Server is listening on port ', this._port);
}
);
}
}