最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Offline PWA communication between clients - Stack Overflow

programmeradmin1浏览0评论

I was wondering if there are any possibilities to efficiently municate and share data between devices using an offline progressive web app without being able to access the internet.

The first things that came into my mind are the Web Bluetooth API (is this even possible?) and generating QR codes (using something like QRCode.js).

Any ideas?

I was wondering if there are any possibilities to efficiently municate and share data between devices using an offline progressive web app without being able to access the internet.

The first things that came into my mind are the Web Bluetooth API (is this even possible?) and generating QR codes (using something like QRCode.js).

Any ideas?

Share Improve this question asked Jul 15, 2020 at 14:31 ˈvɔləˈvɔlə 10.3k11 gold badges72 silver badges105 bronze badges 2
  • What is your use-case? What are the data-types you want to share? And what exactly do you mean by "offline"? Do you mean "no internet connection" (but all interfaces would be available, like bluetooth/wifi)? – Sebastian G. Marinescu Commented Jul 15, 2020 at 16:42
  • @SebastianG.Marinescu The use-case is to share some serialized data. Like I said: Offline means "[...] without being able to access the internet". Bluetooth or WiFi is present on the devices, yes. – ˈvɔlə Commented Jul 15, 2020 at 17:04
Add a ment  | 

3 Answers 3

Reset to default 3

So yes, it is possible, like everything in software development. Here are my thoughts/ideas.

If your serialized data is very small or just a number, then you could also just use Barcodes, with for example https://github./lindell/JsBarcode and https://serratus.github.io/quaggaJS/.

If your serialized data needs to be more flexible or in a custom object and does not exceed 3 KB (or the limits mentioned here) than you best go with QR-codes. You would of course on the receiving part of the application need a reader like for example:

  • https://github./davidshimjs/qrcodejs
  • https://github./cozmo/jsQR
  • https://github./nimiq/qr-scanner

And if you have a lot of data or need real-time-munication between two clients (e. g. Video/File-Transfer/etc.), then currently (as far as I know) you would use WebRTC. For this case you might need a TURN-server in between to establish the direct socket-connection - in this case I advise to take a look at SnapDrop which does it like this.

Good luck and let us know what you ended up using!

I am doing this (kinda) today! https://github./pion/offline-browser-munication. The only downside is one side needs to be a native client, but the demo above allows two people to connect in the same network. They just need to agree on their mDNS Names and DTLS certificate ahead of time.

This functionality could also easily be added to the browser, but it needs to be championed in spec bodies. WebRTC doesn't allow users to choose their mDNS Names yet. You could use the mDNS name of the host though and it would work :)

Interestingly enough you can also use mDNS to determine a hosts name, so maybe could be used in conjunction? I have a jsfiddle here

No, you can't municate or share data between two devices in offline PWA mode. Web Bluetooth API is still under experiment. However, you might be able to generate QR offline but munication won't be possible offline.

发布评论

评论列表(0)

  1. 暂无评论