Skip to Content
Node.js物聯網裝置開發
book

Node.js物聯網裝置開發

by Patrick Mulder, Kelsey Breseman
August 2017
Intermediate to advanced
272 pages
5h 32m
Chinese
GoTop Information, Inc.
Content preview from Node.js物聯網裝置開發
171
第十一章
飛向雲端
先前章節介紹的範例,能夠在區域網路上運作,現在,該是時候看看如何連接橫越網際
網路的各個裝置,但不會直接在裝置間傳遞訊息,而是由網路上的某個節點,擔任訊息
中介器的任務。藉由這台機器扮演中繼轉運站,進一步抽象化裝置所處的位置。
訊息中介器的使用案例通常如下:請想像在各個房屋裡、或是各個城市裡,有著許許多
多的感測器,如果這些感測器需使用
相同
的實體網路,那麼收集資料的工作將會顯得困
難(但因新型態的 LoRaWAN 網路現身,這點已經不再是大問題)。因此可行做法是採
用網路上任何地方都能存取得到的閘道器,或稱之為所謂的「訊息中介器」。
為了能在不同的區域網路間傳遞訊息,有項熱門的技術叫做 MQTTMessage Queue
Telemetry Transport,訊息佇列勘測傳輸)網路協定。藉由 MQTT,我們便能把「發佈 -
訂閱模式」套用到分散四處的多台裝置身上。MQTT 的用法有很多種,你可以設立一台
MQTT 伺服器,或是租用訊息傳輸服務。
發佈 - 訂閱模式為 MQTT 提供了基礎架構,即便自己動手以 JavaScript 語言實作此軟體
模式,也不是太困難。這麼一來,我們就能嘗試各種做法,在網路上散佈資訊狀態,以
及訂閱來自某台裝置的更新訊息。
發佈 - 訂閱模式
對於分散式系統來說,發佈 - 訂閱模式是個非常重要的軟體設計模式。簡言之,其運作
形式類似於報紙或 RSS 消息。許多人或許會對來自不同地方的新聞感到興趣,因此需
要所謂的新聞發報中心,擔任訊息發佈者的角色,讓讀者能夠訂閱。圖 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

金融人工智能:用Python实现AI量化交易

金融人工智能:用Python实现AI量化交易

Yves Hilpisch
快学熟用D3

快学熟用D3

Philipp K. Janert

Publisher Resources

ISBN: 9789864764594