Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

无法发送消息问题

手机h5页面,建立的长连接,设置的心跳是55s。可是我每20s,我就主动去连接,这样就保证了心跳包一直在维持这个链接。现在有个问题就是,在手机上没有任何操作,手机自动锁屏了,等个四五分钟后,在打开手机,就收不到信息了,也监测不到断开连接了。我怎么能知道我的链接是断了的状态呢,或者能知道是异常状态也行


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

兼容性够的话,h5用visibilitychange,该事件监听页面显示状态


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...