当前位置: 首页 > news >正文

图文广告设计百度搜索优化费用

图文广告设计,百度搜索优化费用,河南单招动漫制作专业,齐装网装修公司WebSocket 浏览器通过JavaScript向服务器发出建立WebSocket链接的请求#xff0c;链接建立后#xff0c;客户端和服务器端就可以通过TCP链接直接交互数据。WebSocket链接后可以通过send()方法来向服务器发送数据#xff0c;并通过onnessage事件来接受服务器返回的数据。 创…WebSocket 浏览器通过JavaScript向服务器发出建立WebSocket链接的请求链接建立后客户端和服务器端就可以通过TCP链接直接交互数据。WebSocket链接后可以通过send()方法来向服务器发送数据并通过onnessage事件来接受服务器返回的数据。 创建WebSocket对象 let ws new WebSocket(server); WebSocket参考 WebSocket - Web API 接口参考 | MDN 代码 templateel-row classapp-containerel-button typeprimary clicktestSend主要按钮/el-button/el-row /templatescriptexport default {name: Monitoring,data() {return {websocket: null, // WebSocket对象reconnectInterval: 3000, // 重连间隔时间毫秒restartWebsocket: null , // 重启定时器heartbeatInterval: null, // 心跳定时器};},created() {if (typeof WebSocket undefined) {console.log(您的浏览器不支持WebSocket);} else {this.setupWebSocket(); // 创建WebSocket连接}},methods: {testSend() { // 测试const send {keywords: xxx,}this.sendMessage(JSON.stringify(send));},// websocket初始化setupWebSocket() {this.websocket new WebSocket(ws://xxx); // 创建WebSocket连接this.websocket.onopen this.onWebSocketOpen; // WebSocket连接打开时的处理函数this.websocket.onmessage this.onWebSocketMessage; // 收到WebSocket消息时的处理函数this.websocket.onclose this.onWebSocketClose; // WebSocket连接关闭时的处理函数},closeWebSocket() { // 关闭if (this.websocket) {this.websocket.close(); // 关闭WebSocket连接}},// 开启 WebSocket;启动心跳检测onWebSocketOpen() {console.log(WebSocket connection is open);this.startHeartbeat();},// 处理从服务器接收的消息onWebSocketMessage(event) {if (event.data) {const message JSON.parse(event.data);// 根据业务来处理数据console.log(Message from server , message);}},// 关闭 WebSocket;停止心跳检测onWebSocketClose() {console.log(WebSocket connection is closed);this.stopHeartbeat(); // WebSocket连接关闭时停止心跳检测this.restartWebsocket setTimeout(this.setupWebSocket, this.reconnectInterval); // 在一定时间后重连WebSocket},// 向服务器发送消息sendMessage(message) {if (this.websocket this.websocket.readyState WebSocket.OPEN) {this.websocket.send(message); // 发送消息到WebSocket服务器}},// 开启心跳检测startHeartbeat() {this.heartbeatInterval setInterval(() {if (this.websocket this.websocket.readyState WebSocket.OPEN) {this.websocket.send(); // 发送心跳消息}}, 1000); // 每1秒发送一次心跳},// 停止心跳检测stopHeartbeat() {if (this.heartbeatInterval) {clearInterval(this.heartbeatInterval); // 停止心跳检测定时器}},// 停止重启检测stopRestartWebsocket() {if (this.restartWebsocket) {clearInterval(this.restartWebsocket); // 停止心跳检测定时器}},},beforeDestroy() {this.stopHeartbeat() // 停止心跳this.stopRestartWebsocket() // 停止重启this.closeWebSocket(); // 在组件销毁前关闭WebSocket连接}, } /scriptstyle scoped/style
http://www.hkea.cn/news/14350981/

相关文章:

  • 松江网站开发培训课程班级网站怎么做ppt
  • php做的网站收录工程建设信息网站资质公告
  • 腾讯云备案 网站名称wordpress 导航高亮
  • 网站建设功能的策划书做一套网页设计多少钱
  • 网站维护公司北京网站建设排名
  • 合肥商务科技学校网站建设门户网站开发哪家好
  • ftp 迁移 网站义乌网站建设
  • 支持wap网站的系统网站建设启示
  • 山东住房建设部网站做第三方库个人网站
  • 商城用什么系统做网站flash网站建设技术精粹
  • 网站建设开发哪个好学谁有手机网站
  • 做网站用小公司还是大公司好网站建设的工具
  • 如何开发高端客户裤子seo优化标题
  • 苏州园区建设网站首页短链接转换工具
  • 潍坊程序设计网站建设公司公众号制作开发公司
  • 模板网站和定制网站的区别如何做代刷网站
  • 大连网站如何制作成品网页大全下载
  • 网站开发要营销策略研究论文范文
  • 不通过第三方平台做微网站宝塔一键wordpress
  • 彩票网站代理怎么做深圳市宝安区中心医院
  • 网站导航栏自适应显示南京网站开发联系南京乐识
  • 龙岗住房建设局网站qq登录账号在线登录入口
  • 抚州建设工程造价管理站网站建设网站容易吗
  • 网站提取规则怎么设置简历制作专业机构
  • 网站文件权限设置网站做电商资质
  • 罗湖网站制作公司网页设计的工作流程
  • 做网站需要哪几个板块网站建设与推广综合实训报告册
  • 做百度网站需不需要备案后台网站建设招聘
  • 网站建设的多吗网页设计图片叠加
  • 怎样查找网站域名网站的封面怎么做