4

Pusher - 一個基於 WebSocket 的實時消息推播服務

 2 years ago
source link: https://webber0928.blogspot.com/2016/09/pusher-websocket.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Pusher - 一個基於 WebSocket 的實時消息推播服務

一個聽說非常好用的推播服務,註冊的話可以免費試用一個推播服務,還沒時間試試,只好先記錄一下摟!

原理大概是,當瀏覽器刷新頁面的時候,會向服務端發起一個請求。 服務端收到這個請求後,會返回一個不帶數據的純HTML 空模板。 然後客戶端渲染模板後,再次通過RESTful API 向服務端請求項目的真實數據(JSON 格式),再由客戶端對數據做處理並呈現,得到用戶真正看到的頁面。 之後,會跟Pusher 服務器建立一條WebSocket 的長連接,接收推送信息。 當服務端有任何更新的時候,會發送消息到Pusher 服務器,再由Pusher 服務器傳輸到客戶端瀏覽器,頁面同時也得到更新。 以上,就是一個簡單的過程。

前端引入: https://github.com/pusher/pusher-js
後端引入: https://github.com/pusher/pusher-http-node

幾個教學網址

Laravel 5.1 Events Broadcasting 實務練習
 Laravel 5 Event Broadcasting(事件廣播)進階篇 – Pusher

photo.jpg

By webber0928

一個小菜鳥工程師,對籃球還有夢想的男孩。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK