Giter Club home page Giter Club logo

pusher-webrtc-chat-demo's Introduction

Pusher WebRTC Chat Demo

This is a demo WebRTC application for peer-to-peer chat, meaning you don't necessarily need an Internet connection to send messages. It uses the Pusher realtime API for signalling, allowing devices to discover each other and make a connection using WebRTC.

There's a demo showing this in action, as well as a full tutorial on how to create something like this yourself.

Servers

You can use any server to pass-through the Pusher messages. This demo provides a few of the most common platforms.

/src/_servers/nodejs

The server code required to run the demo using Node.js.

The src/js/datachannel-demo.js file by default is set up to send AJAX requests to the Node.js server.

You'll need to change the config values in src/_servers/nodejs/config.example.js and rename it to config.js, as well as changing the PUSHER_APP_KEY value in src/js/datachannel-demo.js.

You can then get up and running by running the following commands in the terminal:

$ cd /path/to/your/app/src/_servers/nodejs
$ npm install
$ node app.js

And navigating to http://localhost:5001 to see the side-by-side example or http://localhost:5001/chat.html to see the standalone example.

/src/_servers/php

The server code required to run the demo using PHP.

The src/js/datachannel-demo.js file is not set up to send AJAX requests to the PHP server by default. To enable this you'll need to change the AJAX URL in datachannel.openSignalingChannel to point to _servers/php/message.php.

You'll also need to change the config values in src/_servers/php/config.example.php and rename it to config.php, as well as changing the PUSHER_APP_KEY value in src/js/datachannel-demo.js.

Navigate to http://yourdomain.dev/index.html to see the side-by-side example or http://yourdomain.dev/chat.html to see the standalone example. Obviously you'll need to change the domain to wherever you're hosting the PHP files.

/src/_servers/ruby-sinatra

The server code required to run the demo using Ruby Sinatra.

The src/js/datachannel-demo.js file by default is set up to send AJAX requests to the Ruby Sinatra server.

You'll need to change the config values in src/_servers/ruby-sinatra/config.example.rb and rename it to config.rb, as well as changing the PUSHER_APP_KEY value in src/js/datachannel-demo.js.

You can then get up and running by running the following commands in the terminal:

$ cd /path/to/your/app/src/_servers/ruby-sinatra
$ bundle install
$ bundle exec ruby -rubygems app.rb

And navigating to http://localhost:4567 to see the side-by-side example or http://localhost:4567/chat.html to see the standalone example.

Security

It's worth noting that the default PHP server setup in this demo will potentially leave the demo config files for other platforms open to being read. It's highly recommended to implement strict control over which files can be read from your server, or moving the server files into a directory outside of public reach.

When using this demo in your own production environment, you should remove the servers you don't need and ensure that config files aren't readable to the public.

pusher-webrtc-chat-demo's People

Contributors

robhawkes avatar mdpye avatar

Watchers

James Cloos 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.