Giter Site home page Giter Site logo

mehrdad-shokri / peer-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from peerserver/peer-server

0.0 1.0 0.0 14.73 MB

Home Page: http://www.peer-server.com/

License: MIT License

HTML 0.47% CoffeeScript 1.26% CSS 0.14% JavaScript 98.12% Shell 0.01%

peer-server's Introduction

PeerServer: A Server in the Browser with WebRTC

Sophia Westwood and Brie Bunge

([email protected], @sophiawestwood) ([email protected])

About

PeerServer is a peer-to-peer client server using WebRTC, where your browser acts as a server for other browsers across WebRTC peer-to-peer data channels. You can create a client-server within your browser tab, upload content, and generate dynamic content using a mock-database, templating system, and sessions. Any client browser that connects to your client server will behave as if it is talking to a traditional server while in fact exclusively hitting your server.

This system allows you to quickly create a decentralized, short-lived web application where all the content lives within your browser. The traditional server only performs the initial handshake between the client-browsers and the client-server; your browser serves all other content peer-to-peer.

We built PeerServer in 8 weeks for our Stanford senior project in Spring 2013.

poster

Videos

Get started with PeerServer and learn about how it works.

Getting Started Video

Go more in-depth with a more complicated website that uses additional features.

More In-depth Video

Getting Started

This tutorial will walk you through how to make the canonical "Hello, world." page using PeerServer.

Create a new server

  1. Go to www.peer-server.com
  2. Type your server name in the input field. Note: If the server name is already taken, you will be prompted to choose another name.
  3. Click the "Create PeerServer" button. You will be asked to select a template. For the purposes of this tutorial, you should choose "Empty Template." But, feel free to explore the others. :) create server
  4. A new tab should open, revealing your new server! new server
  5. Click "Open Browser" in the nav bar.
  6. Marvel at your very own "Hello, world." page.

What just happened?

You might be wondering, "Well, okay. Why is this so awesome?" What just transpired is really cool! The first tab is your server, so its responsibility is to serve pages. But, how can a tab serve a webpage? WebRTC allows for between-browser communication. PeerServer uses the data channel capability of WebRTC. The data channel lets you send any sort of data between tabs. In this case, the server tab sends HTTP-like data (analogous to a HTTP server, such as Apache). The second tab is the browser, or client, of the server in the first tab. The PeerServer code on the browser/client tab overrides the standard HTTP requests, ensuring that everything is sent over the data channel.

Read more on the inner workings of PeerServer

A tour of the server

  • Let's head back to the server tab.
  • Click on "index.html" in the sidebar. This is the page contains the content you saw in the PeerServer browser's tab. index page
  • Next, click on "default" under "Dynamic Files". When the PeerServer browser visits http://www.peer-server.com/connect/[your server name]/, this default dynamic file is loaded. default dynamic file default dynamic file - annotated

(Optional) Running the project locally

We just walked through how to create a server at peer-server.com. Here is how to run your own instance locally.

After running git clone: From the scripts directory, run coffee.sh to compile the Coffeescript files and handlebars.sh to compile the Handlebars files.

Then, run server.sh to start the server.

You should now be able to access http://localhost:8890 successfully!

peer-server's People

Contributors

brieb avatar jgasperetti avatar swestwood avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.