4

Can anyone explain me the possibilities of creating a web chat (i.e similar to whatsappweb) which works without internet connections the only possible way that these device communicate is either by WiFi or Bluetooth (i.e Peer to peer). If it is not possible on earth could then explain why?

I've come across some javascript files like peer.js. But it uses internet i think. I want it to work without internet connectivity.

Thanks in advance.

VinoPravin
  • 947
  • 3
  • 17
  • 32
  • 2
    The browser needs internet to connect ... to anything. If you want to use a phones other means of communicating, you'll need a native app, built with native languages. – adeneo Apr 13 '17 at 08:34
  • you need a server in your network which is accessible in your browser and then you could implement something like that – ave4496 Apr 13 '17 at 08:35
  • 1
    By "wi-fi" do you mean a normal wireless connection but without a functioning router to the wider internet, or a specific kind of peer-to-peer (ad-hoc) wireless network? – Dai Apr 13 '17 at 08:35
  • yes! within a particular range that the wifi covers – VinoPravin Apr 13 '17 at 08:36
  • 2
    Works on WiFi? wifi without internet? – Kuldeep Singh Apr 13 '17 at 08:36

3 Answers3

5

With WebRTC it is possible to establish peer-to-peer communication between web-browsers in the same local network: https://developer.mozilla.org/en-US/docs/Web/Guide/API/WebRTC/Peer-to-peer_communications_with_WebRTC

A server is only needed for communication outside of a local network: http://blog.vline.com/post/63765098884/webrtc-if-its-p2p-why-do-i-need-a-server

There is another demonstration in this page: https://hacks.mozilla.org/2013/05/embedding-webrtc-video-chat-right-into-your-website/

However WebRTC is a relatively new system that is not widely supported - so consider it experimental at this stage - but it has the backing of Mozilla, so it might end-up somewhere.

However you are limited to the capabilities that WebRTC provides - and as your code is still JavaScript that runs in the browser you will not have access to any kind of actual networking API (such as Berkeley Sockets) or lower-level control of hardware, such as the ability to create Ad-hoc Wi-Fi networks, new Bluetooth Personal Area Networks, or LE Bluetooth connections... at present.

Google is working on making a Bluetooth API available that runs in the browser. Presently it is only available to Chrome Extensions, but it may soon be available in web-pages in general: https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web

Dai
  • 141,631
  • 28
  • 261
  • 374
  • Yeah! this is wat am looking! I also seen the WebRTC thing! The local network u r referring here is to connect both the computer to the same wifi, right? – VinoPravin Apr 13 '17 at 08:44
  • 1
    @VinoPravin "connect to the same wifi" is ambiguous - as you could be referring to Ad-hoc networks, or to the same Infrastructure access-point, or to the same network with different access-points (same subnet), or the same physical network in different subnets but with working routers. Please be more precise. – Dai Apr 13 '17 at 08:45
1

Ofcourse there is a way to make this happen. You would have to set up a webserver on the device with this webapp. You could then connect with localhost or 127.0.0.1 . Other people would have to join your hotspot and connect to your ip address.

If you want to connect automaticly you would have to write a real app.

SpaceNinjaApe
  • 312
  • 1
  • 13
-1

Browsers run in a "contained" mode. No hardware access is possible from any script ran inside the browser, thus there's no way to initialize and setup the device to start direct communication.

LCO TEC BAJA
  • 678
  • 5
  • 5
  • No direct hardware access is required other than what's already allowed - sending information over HTTP/S to and from known endpoints (ie, webrtc). – Logos Jul 10 '17 at 18:33