Use Firefox OS as a web server

For an art project, I would like to have several distributed devices that can output sound. Firefox OS devices seem optimal. They bring the necessary equipment, and I know HTML and JS well. But I also need a management web server.

In my opinion, an OS device for OS can act as a WiFi access point ("Share Internet"). However, it cannot act as a small web server for other devices that connect to the network without an Internet connection. The APIs for native applications seem simply not powerful enough.

But maybe I'm wrong (I would like to be). So, is a Firefox OS device capable of running like a small web server?

0
source share
4 answers

httpd.js did not work because of the box for me. But that led me to the right path. Then I found this, and after a little change in the settings and updating the code, I got a super-simple server system.

function startListen(){
  console.log("Initializing server");
  var socketServer = navigator.mozTCPSocket.listen(8080);

  socketServer.onconnect = function(conn){
    console.log("connected", conn, conn.ondata);
    conn.ondata = function(ev){
      console.log("Got request: ", ev);   
      conn.send("Ok. Got client on port " + conn.port);
      conn.close();
    };
    conn.onclose = function(ev){
      console.log("Client left:", ev);
    }
  };
  socketServer.onerror = function(ev){
    console.log("Failed to start: ", ev);
  };
}
startListen();

Permission required tcp-socket.

With this code, I was able to run this in a Firefox OS simulator, directed my browser to open http: // localhost: 8080 and get the response and logs in the console.

PS. . , . Firefox OS " ", , ( , ).

+1

httpd.js. FirefoxOS 2.0.

// create a server object
server = new HttpServer();

// configure /sdcard/public as document root
server.get("/", "/sdcard/public");

// launch on port 3000
server.start(3000);
0

, , - WebRTC .

0

Mozilla Hacks, , :

HTTP- Firefox OS

0
source

Source: https://habr.com/ru/post/1671421/


All Articles