//声明连接,房间号,名称
ws
roomCount = 100
name
IP='ws://127.0.0.1:8888'
// websocket建立连接
link(){
//建立连接
this.ws = new WebSocket(this.IP)
//连接成立触发
this.ws.onopen = this.onopen()
}
onopen(){
console.log('success connected')
var randomScore = parseInt(Math.random()*3)
console.log('parseInt(Math.random()*5)=============>'+randomScore)
console.log(this.ws.readyState)
while(true){
if(this.ws.readyState==1){
this.ws.send({type:0,score:randomScore})
break
}
}
}
```}
求websocket中nodejs已经显示连接上,但是readystate还是0,急
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-