All Projects → t-mullen → Hyperhost

t-mullen / Hyperhost

Licence: mit
P2P Node Servers in the Browser

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Hyperhost

Pikachu Volleyball P2p Online
Pikachu Volleyball peer-to-peer online via WebRTC data channels
Stars: ✭ 160 (+247.83%)
Mutual labels:  webrtc, peer-to-peer
peerjs-python
Python port of PeerJS client
Stars: ✭ 56 (+21.74%)
Mutual labels:  webrtc, peer-to-peer
Trango Self Hosted
Host trango and communicate with those around you without the internet!
Stars: ✭ 164 (+256.52%)
Mutual labels:  webrtc, peer-to-peer
Nile.js
Server
Stars: ✭ 1,757 (+3719.57%)
Mutual labels:  webrtc, peer-to-peer
Sharedrop
Easy P2P file transfer powered by WebRTC - inspired by Apple AirDrop
Stars: ✭ 5,222 (+11252.17%)
Mutual labels:  webrtc, peer-to-peer
Wt Tracker
High-performance WebTorrent tracker
Stars: ✭ 144 (+213.04%)
Mutual labels:  webrtc, peer-to-peer
Peer To Peer Cue System
Cue system for simple two-way communication and visual signaling using a PeerJS peer-to-peer connection.
Stars: ✭ 190 (+313.04%)
Mutual labels:  webrtc, peer-to-peer
Rn Voice Video Call
Usage of WebRTC for voice & video call with peer-to-peer or conference with Login and Register screen using response & Async storage with Call Dis/Connect, Failed and Idle views in react native. Youtube:
Stars: ✭ 100 (+117.39%)
Mutual labels:  webrtc, peer-to-peer
Libdatachannel
C/C++ WebRTC Data Channels and Media Transport standalone library
Stars: ✭ 336 (+630.43%)
Mutual labels:  webrtc, peer-to-peer
Decentralized Video Chat
🚀 Zipcall- Acquired @ 250k users 🚀 Peer to peer browser video calling platform with unmatched video quality and latency.
Stars: ✭ 3,284 (+7039.13%)
Mutual labels:  webrtc, peer-to-peer
Stun
A Go implementation of STUN
Stars: ✭ 141 (+206.52%)
Mutual labels:  webrtc, peer-to-peer
Uproxy P2p
Internet without borders
Stars: ✭ 798 (+1634.78%)
Mutual labels:  webrtc, peer-to-peer
Ice
A Go implementation of ICE
Stars: ✭ 114 (+147.83%)
Mutual labels:  webrtc, peer-to-peer
P2p Cdn Sdk Javascript
Free p2p cdn github javascript sdk to reduce video streaming costs of live and on demand video using webrtc by upto 90% and improve scalability by 6x - 🚀 Vadootv 🚀
Stars: ✭ 158 (+243.48%)
Mutual labels:  webrtc, peer-to-peer
Netsix
Netsix allows you to share videos with your friends in a real peer-to-peer manner using WebRTC.
Stars: ✭ 113 (+145.65%)
Mutual labels:  webrtc, peer-to-peer
Video Meeting
Google Meet / Zoom clone in a few lines of code
Stars: ✭ 187 (+306.52%)
Mutual labels:  webrtc, peer-to-peer
Laplace
Laplace is an open-source project to enable screen sharing directly via browser. Based on WebRTC for low latency peer-to-peer connections, and WebSocket implemented in golang for signaling.
Stars: ✭ 81 (+76.09%)
Mutual labels:  webrtc, peer-to-peer
Laverna
Laverna is a JavaScript note taking application with Markdown editor and encryption support. Consider it like open source alternative to Evernote.
Stars: ✭ 8,770 (+18965.22%)
Mutual labels:  webrtc, peer-to-peer
Oorja
[archived] effortless video-voice chat with realtime collaborative features. extensible using react components 🙌
Stars: ✭ 270 (+486.96%)
Mutual labels:  webrtc, peer-to-peer
Gfile
Direct file transfer over WebRTC
Stars: ✭ 598 (+1200%)
Mutual labels:  webrtc, peer-to-peer


HyperHost
HyperHost

Peer-To-Peer Node Servers in the Browser.


Currently just a prototype. A production version is in development.

Demo

Drag and drop your website (with at least an index.html) into https://t-mullen.github.io/hyperhost/.
It will be instantly served from your browser via WebRTC.

Node Servers

HyperHost emulates a Node server in your browser by replacing HTTP requests with WebRTC connections.
This, along with the huge number of Browserified Node modules, allows you to run a full server from your browser.

Drag and drop a folder containing a file an index.html and a HH-server.js. Inside HH-server.js, you can put your Node start script.

Example of a HH-server.js:

// HyperHost gives you access to a Node-like 'require'
var hyperhost = require('hyperhost'); // This special module lets us handle WebRTC connections
var fs = require('browserify-fs');    // require any module that can be Browserified
var custom = require('custom');       // require custom modules that you upload with the "HH-" prefix (ie HH-custom.js"

var app = hyperhost.createApp();
app.get('/', function (req, res) {    

    custom.someFunction();
    
    fs.mkdir('/home');
    fs.writeFile('/home/hello-world.txt', "browserify-fs is used to create a virtual file system!");
    
    // Send any data over WebRTC (objects, files, blobs)
    res.send({
        exampleData: "send any serializable data",
        a : []
    });
});

app.listen();

Pull from NPM

You can pull NPM modules via WZRD by adding a package.json:

{
  "name": "MyNodeApp",
  "dependencies": { 
    "browserify-fs": ">1.0.0", // These are modules that will be pulled from NPM
    "crypto-browserify" : "",  //
  }
}

Client Code

Calls to this Node server can only be made from the pages being hosted. (Think of it like CORS)
Including hyperclient.js in your hosted files provides the HyperRequest object, similar to the XMLHttpRequest object.

//Here is an example request
var hyp = HyperRequest(); //Create a new HyperRequest
hyp.onload = function (response) { //Set the callback
    console.log(response);
    document.getElementById("output").innerHTML = JSON.stringify(response);
}
hyp.open("GET", "/"); //Set the method and route
hyp.send({ //Send arbitrary data to server
    message: "hello",
    moreData: [12, 42, 21, ],
    evenMore: {}
});

How It Works

First, the files you upload are read and seperated into static assets (images, HTML, CSS, etc) and server code (Javascript with the "HH-" prefix, or a package.json).

The static assets are base64 encoded and bundled into a single large file (with some extra scripts for changing page). The server code is injected into the host page, along with any external NPM modules. The server is now running.

When a client connects, they first connect to a signalling server, which helps with the creation of a WebRTC connection to the host page. When a connection is established, the static resource bundle is sent and displayed by the client.

The same connection is used to handle any subsequent requests to the host (by way of the HyperRequest object). These requests are forwarded to the server code, which sends a response back the same way.

Custom Usage

The demo at https://rationalcoding.github.io/hyperhost/ is just one use-case.
You can easily integrate instant hosting over WebRTC into any project.

var host = new HyperHost(); // Create a new HyperHost instance

host.on('ready', function(url){
  window.open(url); // Open the window when a URL is available
});

host.io.on('digest', function(){
    host.launch();  // Launch the server when digest is completed
});

// Digest the content to be served.
host.io.contentTree([
    {
       name : 'index.html',
       content : '<html><body>Hello World</body></html>'
    },
    {
        name : "HH-server.js",
        content : 'var hyperhost = require("hyperhost"); console.log(hyperhost);'
    }
]);

Great for demos and hackathons!

Upcoming Features:

  • Distributed hosting - Allow clients to opt-in to helping you host the site via a mesh network.
  • More ways to upload your site.
  • Full documentation and better examples.
  • More custom modules (WebSockets, MySQL, templating views)

Current Limitations:

  • Any Node modules used must be Browserify-able.
  • The host must be running Chrome. The client can be any browser supporting WebRTC.
  • Very large pages can freeze up when clients attempt to load them.
  • Relative URLs pointing to hosted files inside Javascript files will not work. (JS cannot easily be refactored, an API for allowing this is forthcoming)
  • The require method only supports module names and not paths. require('custom'), not require('./custom'). (Use Browserify before uploading if you need this behaviour)

Notes:
You can host the files in this repo anywhere (even on a file:// domain!) if you don't want to use Github's servers for the initial resources. You can also use any PeerJS signalling server (with the addition of a /api/peers route that returns all peer IDs)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].