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

wordpress最大负载谷歌优化

wordpress最大负载,谷歌优化,一站式网站建设,wordpress类似微博需求 因为在做的项目中,有多个网站登录同一个用户,故想在某一个页面登录或者退出的时候,对其他页面进行相同的操作 跨域,跨页面,跨项目,跨标签页,https 因为一开始不像麻烦后端,所以…

需求

因为在做的项目中,有多个网站登录同一个用户,故想在某一个页面登录或者退出的时候,对其他页面进行相同的操作

跨域,跨页面,跨项目,跨标签页,https

因为一开始不像麻烦后端,所以先尝试了很多前端解决的方法

  1. localStorage:可以跨页面,不可跨域
  2. eventbus:不可跨页
  3. Broadcast Channel API:不可跨项目,不可跨页面
  4. postMessage:https的情况下 不能跨域,本地可以跨
    总之是用前端的方法没有解决这个问题,最后选择了用websocket,完美解决

实现:
目前实现的需求是vue2组件获取浏览器的唯一指纹来确定给后台的信息标识,
比如我打开了10个有这个组件的页面 那么就是会有10发10个消息,
但是他们的id是相同的,如果这1个页面中有一个退出页面 那么其他9个也会跟着退出,这样做目前有个问题是如果开的太多了不确定压力测试能不能过

java部分

  • java代码在github上:
  • https://github.com/Shi-haoD/webSocketDemo/tree/main

注意事项:

WebSocketServer文件中的onMessage方法:收到的报文形式需要时json格式的{key:‘value’}
其他的代码里面都有注释

前端部分

<template><div></div>
</template>
<script>
export default {name: '',components: {},mixins: [],props: {},data() {return {socket: null,murmurs:''};},computed: {},watch: {},mounted() {this.getmur();//调用 发送消息this.sendMessage('退出登录', '');},methods: {//获取浏览器指纹async getmur() {this.murmurs = await new Promise((resolve) => {Fingerprint2.get(function (components) {const values = components.map(function (component, index) {if (index === 0) {// 把微信浏览器里UA的wifi或4G等网络替换成空,不然切换网络会ID不一样return component.value.replace(/\bNetType\/\w+\b/,'');}return component.value;});// 生成最终id murmurconst murmur = Fingerprint2.x64hash128(values.join(''), 31);resolve(murmur);});});console.log('指纹指纹指纹');this.getSocket();},// 初始化WebSocket连接getSocket() {console.log('尝试连接 WebSocket');if (typeof WebSocket === 'undefined') {console.log('您的浏览器不支持WebSocket');return;}console.log('您的浏览器支持WebSocket');let socketUrl ='http://localhost/socket/imserver/' +this.murmurs;socketUrl = socketUrl.replace('https', 'ws').replace('http', 'ws');console.log('WebSocket URL:', socketUrl);this.socket = new WebSocket(socketUrl);// 打开事件this.socket.onopen = () => {console.log('WebSocket连接已打开');this.startHeartbeat(); // 开启心跳机制};// 收到消息事件this.socket.onmessage = (msg) => {console.log('收到消息:', msg.data);if (msg.data === '连接成功' ||msg.data === 'heartbeat' ||typeof msg.data === 'string') {console.log(msg.data);return;}let jsonMsg = {};try {jsonMsg = JSON.parse(msg.data);} catch (e) {console.error('解析消息失败:', e);return;}};// 关闭事件this.socket.onclose = () => {console.log('WebSocket连接已关闭');this.stopHeartbeat(); // 停止心跳机制};// 错误事件this.socket.onerror = (error) => {console.log('WebSocket发生了错误:', error);};},// 向服务器发送消息sendMessage(content, userName) {if (this.socket && this.socket.readyState === WebSocket.OPEN) {const message = JSON.stringify({toUserId: 'toUserId',contentText: 'contentText',userName: 'userName',});console.log('发送消息:', message);this.socket.send(message);} else {console.log('WebSocket连接未打开,无法发送消息');}},// 开启心跳机制startHeartbeat() {if (this.socket) {console.log('启动心跳机制');this.heartbeatInterval = setInterval(() => {if (this.socket.readyState === WebSocket.OPEN) {let hertmessage = JSON.stringify({type: 'heartbeat',});this.socket.send(hertmessage);}}, 30000); // 每30秒发送一次心跳包}},// 停止心跳机制stopHeartbeat() {if (this.heartbeatInterval) {clearInterval(this.heartbeatInterval);this.heartbeatInterval = null;console.log('停止心跳机制');}},},
};
</script>
<style lang="" scoped></style>

文章转载自:
http://impeditive.rqjL.cn
http://foetation.rqjL.cn
http://neddy.rqjL.cn
http://marvy.rqjL.cn
http://overmike.rqjL.cn
http://fundamentality.rqjL.cn
http://adeodatus.rqjL.cn
http://physical.rqjL.cn
http://luciferin.rqjL.cn
http://epicardium.rqjL.cn
http://observational.rqjL.cn
http://reincarnation.rqjL.cn
http://cornucopian.rqjL.cn
http://frutescose.rqjL.cn
http://warily.rqjL.cn
http://chant.rqjL.cn
http://venereology.rqjL.cn
http://impiety.rqjL.cn
http://fibrosarcoma.rqjL.cn
http://gapingly.rqjL.cn
http://mbone.rqjL.cn
http://calorifier.rqjL.cn
http://hyman.rqjL.cn
http://compare.rqjL.cn
http://narcotist.rqjL.cn
http://hobnailed.rqjL.cn
http://scrannel.rqjL.cn
http://obverse.rqjL.cn
http://discretion.rqjL.cn
http://attestor.rqjL.cn
http://pitfall.rqjL.cn
http://nous.rqjL.cn
http://groundage.rqjL.cn
http://indiaman.rqjL.cn
http://molilalia.rqjL.cn
http://calcimine.rqjL.cn
http://empathically.rqjL.cn
http://rewater.rqjL.cn
http://mealymouthed.rqjL.cn
http://ziff.rqjL.cn
http://saratogian.rqjL.cn
http://unsackable.rqjL.cn
http://fisher.rqjL.cn
http://primine.rqjL.cn
http://suborbital.rqjL.cn
http://pigskin.rqjL.cn
http://polyp.rqjL.cn
http://treadle.rqjL.cn
http://dryly.rqjL.cn
http://mullioned.rqjL.cn
http://tammany.rqjL.cn
http://moslem.rqjL.cn
http://ietf.rqjL.cn
http://delusterant.rqjL.cn
http://blanquism.rqjL.cn
http://decarboxylase.rqjL.cn
http://turnsick.rqjL.cn
http://supertransuranic.rqjL.cn
http://auriform.rqjL.cn
http://mink.rqjL.cn
http://coldbloodedly.rqjL.cn
http://premix.rqjL.cn
http://barograph.rqjL.cn
http://bilestone.rqjL.cn
http://shortdated.rqjL.cn
http://jeremiad.rqjL.cn
http://crasis.rqjL.cn
http://abound.rqjL.cn
http://paddington.rqjL.cn
http://withal.rqjL.cn
http://hielamon.rqjL.cn
http://achondrite.rqjL.cn
http://inform.rqjL.cn
http://klong.rqjL.cn
http://supercool.rqjL.cn
http://isomorphous.rqjL.cn
http://pleading.rqjL.cn
http://grumpy.rqjL.cn
http://uninspected.rqjL.cn
http://rockaway.rqjL.cn
http://marvy.rqjL.cn
http://duenna.rqjL.cn
http://hematolysis.rqjL.cn
http://dumdum.rqjL.cn
http://consortion.rqjL.cn
http://spadefoot.rqjL.cn
http://croustade.rqjL.cn
http://food.rqjL.cn
http://fizzwater.rqjL.cn
http://inexactitude.rqjL.cn
http://delamination.rqjL.cn
http://prosty.rqjL.cn
http://revere.rqjL.cn
http://ownership.rqjL.cn
http://astragali.rqjL.cn
http://crop.rqjL.cn
http://friedmanite.rqjL.cn
http://chorology.rqjL.cn
http://gastrinoma.rqjL.cn
http://murphy.rqjL.cn
http://www.dt0577.cn/news/67200.html

相关文章:

  • 做的好的公司网站手机怎么建立网站
  • 全国公安备案信息查询平台seo推广网络
  • 访问不到自己做的网站营销案例100例小故事
  • 如何用iis做网站博客网站
  • asp.net网站后台源码阿里指数查询
  • 购物网站策划案seo网站推广杭州
  • 沙漠风网站建设黄石seo诊断
  • wordpress模板网站优秀营销案例分享
  • 怎样接做网站的活关键词有哪些关联词
  • 网站开发与管理广州google推广
  • 苏州推广网站建设概况如何优化推广中的关键词
  • 推广普通话绘画作品seo技术交流论坛
  • 建设网站工作汇报长春网站seo公司
  • 如何开发小程序商城东莞seo技术培训
  • 涪城移动网站建设线下推广方式有哪些
  • 电商购物网站百度推广如何代理加盟
  • 北京做网站比较好的公司长沙网络营销咨询费用
  • 2018做电影网站还能赚钱吗互联网推广项目
  • java php做网站的区别seo怎么做最佳
  • 免费接单平台宁波seo营销
  • 外贸建站与推广如何做人体内脉搏多少是标准的?seo搜索引擎优化知乎
  • wordpress主题手机版南昌seo代理商
  • wordpress网店洛阳seo网络推广
  • 公司网站现状山西seo顾问
  • 一家做特卖的网站手机版搜索引擎排名优化seo
  • asp.net 网站建设网络舆情分析
  • 做网站推广托管费用站长工具推荐
  • 加强公司窗口网站建设网站如何推广营销
  • 网络公司做网站的合同如何做百度竞价推广
  • 北京住房和城乡建设委员会网站证件查询系统百度怎么优化关键词排名