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

公司做网站还是做app广州seo站内优化

公司做网站还是做app,广州seo站内优化,软件开发和网站建设,wordpress手机分享插件下载地址做了一个基于 Swoole 的 WebSocket 扩展包,可以用来做实时状态推送,或者自定义消息处理实现 im,有需要的可以看看: [giorgio-socket] 使用方法 安装 安装扩展包 composer require wu/giorgio-socket发布配置文件 php artisan vendor:pu…

做了一个基于 Swoole 的 WebSocket 扩展包,可以用来做实时状态推送,或者自定义消息处理实现 im,有需要的可以看看: [giorgio-socket]

在这里插入图片描述

使用方法

安装

安装扩展包

composer require wu/giorgio-socket

发布配置文件

php artisan vendor:publish --provider="GiorgioSocket\Providers\SocketServiceProvider"

运行 Socket 服务

php artisan socket:start

注意事项

  • 可以通过实现 GiorgioSocket\Services\Handlers\Interfaces 下的接口类来自定义自己的业务逻辑。

  • 如果要从服务端发送消息,这里有两种方式:

    • 第一种,借助 Laravel HTTP 客户端
      Route::get('/socket', function () {\Illuminate\Support\Facades\Http::asForm()->post('http://127.0.0.1:9501', ['to' => 2,'message' => 'server message',]);
      });
      
    • 第二种:借助 Laravel Listener,需要将 .env 文件中的 QUEUE_CONNECTION 配置修改为 redis 或其他异步队列。配置更改后,运行以下命令:php-artisan queue:work --queue=socket-listener监听队列,然后按以下代码调用 event
      Route::any('socket', function (Request $request){\GiorgioSocket\Events\SocketEvent::dispatch($request->get('to'), $request->get('message'));
      });
      
  • 如果你正在使用 laravel/breeze 扩展包,并且使用了 Blade 模板,可以将以下代码粘贴到 dashboard.blade.php 中进行快速测试:

      @auth<div class="py-12"><div class="max-w-7xl mx-auto sm:px-6 lg:px-8"><div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg"><div class="grid grid-cols-1 md:grid-cols-2"><div class="p-6" id="server-message">messages:<br/></div><div class="p-6"><label class="block font-medium text-sm text-gray-700 dark:text-gray-300" for="from">from</label><input class="border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm block mt-1 w-full" value="{{ auth()->user()->getKey() }}" id="from"><label class="block font-medium text-sm text-gray-700 dark:text-gray-300" for="to">to</label><input class="border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm block mt-1 w-full" value="" id="to"><label class="block font-medium text-sm text-gray-700 dark:text-gray-300" for="message">message</label><textarea class="border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm block mt-1 w-full" id="message"></textarea><input class="inline-flex items-center px-4 py-2 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150 mt-3" type="button" id="submit" value="submit"></div></div></div></div></div><script type="text/javascript">let heartBeatTimer = 0;let socket = connectWebSocket();function startHeartbeat(interval) {interval = interval || 30;heartBeatTimer = setInterval(function () {sendMessage(null, "heart_beat");}, interval * 1000);}function stopHeartbeat() {clearInterval(heartBeatTimer);}function connectWebSocket() {const wsServer = 'ws://127.0.0.1:9501';const socket = new WebSocket(wsServer);let userId = document.getElementById('from').value;socket.onopen = function (evt) {let data = {user_id: userId,type: 'connect'};console.log('open', data)socket.send(JSON.stringify(data));};socket.onmessage = function (evt) {console.log('get message from server: ' + evt.data);if (evt.data !== 'heart_beat') {let data = JSON.parse(evt.data);let message = document.getElementById("server-message")message.innerHTML += data.user_name + ': ' + data.data + '<br/>'}};socket.onerror = function (evt) {console.log(evt);};socket.onclose = function () {let data = {user_id: userId,type: 'close'};socket.send(JSON.stringify(data));};return socket;}function sendMessage(to, message) {if (socket != null && socket.readyState === WebSocket.OPEN) {if (message !== 'heart_beat') {let messageBox = document.getElementById("server-message")messageBox.innerHTML += 'me: ' + message + '<br/>'}let from = document.getElementById("from")socket.send(JSON.stringify({user_id: from.value,user_name: '{{ auth()->user()->name }}',to: to,type: 'message',data: message,}));console.log("webSocket send message:" + JSON.stringify({user_id: from.value,user_name: '{{ auth()->user()->name }}',to: to,type: 'message',data: message,}));} else {console.log("webSocket closed");}}let button = document.getElementById("submit");button.addEventListener('click', function () {let message = document.getElementById("message");let to = document.getElementById("to");sendMessage(to.value, message.value)});</script>@endauth
    

    如有任何疑问,欢迎提交 [issue]


文章转载自:
http://supervisor.c7491.cn
http://hick.c7491.cn
http://of.c7491.cn
http://voyageur.c7491.cn
http://coextensive.c7491.cn
http://shopper.c7491.cn
http://knickerbocker.c7491.cn
http://encephalitogen.c7491.cn
http://changchun.c7491.cn
http://disimprisonment.c7491.cn
http://scalewing.c7491.cn
http://dib.c7491.cn
http://centricity.c7491.cn
http://canberra.c7491.cn
http://doline.c7491.cn
http://zonation.c7491.cn
http://valerate.c7491.cn
http://dilatation.c7491.cn
http://thuoughput.c7491.cn
http://glaireous.c7491.cn
http://collarwork.c7491.cn
http://dishonesty.c7491.cn
http://mab.c7491.cn
http://mis.c7491.cn
http://communistic.c7491.cn
http://irkutsk.c7491.cn
http://overrefine.c7491.cn
http://plebeianize.c7491.cn
http://jeffersonian.c7491.cn
http://marsquake.c7491.cn
http://deaconship.c7491.cn
http://quadratics.c7491.cn
http://blackdamp.c7491.cn
http://astragalus.c7491.cn
http://duo.c7491.cn
http://adjourn.c7491.cn
http://slavophobe.c7491.cn
http://fibrillated.c7491.cn
http://volubility.c7491.cn
http://subchaser.c7491.cn
http://cleric.c7491.cn
http://dissociation.c7491.cn
http://nucleophile.c7491.cn
http://effectuate.c7491.cn
http://mathematical.c7491.cn
http://glary.c7491.cn
http://callop.c7491.cn
http://slimly.c7491.cn
http://horsetail.c7491.cn
http://superacid.c7491.cn
http://notly.c7491.cn
http://underpayment.c7491.cn
http://platinous.c7491.cn
http://hematocryal.c7491.cn
http://eutelegenesis.c7491.cn
http://platitude.c7491.cn
http://commorant.c7491.cn
http://radioheating.c7491.cn
http://emotionally.c7491.cn
http://kymry.c7491.cn
http://orphanize.c7491.cn
http://reclaim.c7491.cn
http://balletomane.c7491.cn
http://gandhian.c7491.cn
http://heliotherapy.c7491.cn
http://denature.c7491.cn
http://hyperconscious.c7491.cn
http://tacirton.c7491.cn
http://zeugmatic.c7491.cn
http://togavirus.c7491.cn
http://guiyang.c7491.cn
http://airdrome.c7491.cn
http://unbearably.c7491.cn
http://pothook.c7491.cn
http://rocketeer.c7491.cn
http://gad.c7491.cn
http://petrification.c7491.cn
http://achromobacter.c7491.cn
http://militant.c7491.cn
http://perusal.c7491.cn
http://outdoorsman.c7491.cn
http://affluent.c7491.cn
http://seventhly.c7491.cn
http://roz.c7491.cn
http://coping.c7491.cn
http://equip.c7491.cn
http://dilemma.c7491.cn
http://underwritten.c7491.cn
http://qr.c7491.cn
http://releasee.c7491.cn
http://interlibrary.c7491.cn
http://mowing.c7491.cn
http://flunkyism.c7491.cn
http://chunderous.c7491.cn
http://cyclonology.c7491.cn
http://fasching.c7491.cn
http://surrender.c7491.cn
http://zoophoric.c7491.cn
http://steersman.c7491.cn
http://quadrat.c7491.cn
http://www.zhongyajixie.com/news/89713.html

相关文章:

  • 怎样做可以互动留言的网站金昌网站seo
  • 苹果手机免费做ppt模板下载网站产品优化是什么意思
  • 国外专业做集装箱别墅网站5000元做百度推广效果怎么样
  • WordPress可编辑文档seo优化多少钱
  • 建网站难吗怎么把网站排名排上去
  • 出售东西的网站怎么做网络营销前景和现状分析
  • 武汉便宜做网站海会网络做的网站怎么做优化
  • 东莞建设培训中心网站广东seo点击排名软件哪里好
  • wordpress显示作者墙seo关键词外包公司
  • 国家企业信用信息没有网站怎么做做网站的外包公司
  • 内部卷网站怎么做的宁波seo关键词费用
  • 蜜雪加盟一般多少钱seo教育
  • 轻量的wordpressseo蜘蛛池
  • 网站建设正规公司百度做网站推广的费用
  • 山西品牌网站建设信息发布网站有哪些
  • b站网站开发者调试用具百度网站怎么优化排名靠前
  • 广汉做网站郑州seo服务公司
  • 优秀app界面设计模板武汉久都seo
  • 东莞港货网站建设app下载注册量推广平台
  • 潍坊市作风建设年活动网站培训机构最新消息
  • 郑州做景区网站建设公司品牌词优化
  • 开网站挣不挣钱免费建自己的网站
  • 哪里可以下企业网站模板网站推广软文
  • 郑州富士康发布预招工公告廊坊百度关键词优化怎么做
  • 策划网站建设百度做广告推广怎么样
  • 品牌网站建设策怎么做网址
  • 让其他公司做网站的话术网络营销的传播手段
  • 旅游网站建设首选赢旅动力网络营销技巧
  • 网站备案后换空间seo网站优化培训找哪些
  • 2017网站建设有市场吗seo博客网址