Coder Social home page Coder Social logo

fluctus's Introduction

EchoPhone

EchoPhone provides developers with an SDK that creates a bridge between native mobile inputs and sensor data with desktop interaction, requiring minimal code and knowledge of the underlying technologies.

Installation

npm install echo-phone

Getting Started

EchoPhone's server functions are currently Express middleware. Implementing EchoPhone will require Express to be installed and required.

EchoPhone's server-side functionality can be enable with just a couple lines of javascrips: Just require the module and pass it the server object of your app

const echo = require('echo-phone')(server);

Then have your app use the returned object as middleware

app.use(echo.init());

EchoPhone will handle the mobile-to-desktop connections for you!

A Simple Example

In server.js:

const express = require('express');
const app = express();
const server = require('http').Server(app); // get the server object from the app instance
const path = require('path');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const useragent = require('express-useragent');
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
const echo = require('echo-phone')(server);
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

app.use(express.static(path.join(`${__dirname}/../client`)));
app.use(useragent.express()); // TODO tie this into our library somehow?
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.set('view engine', 'ejs');
// *-*-*-*-*-*-*-*-*-
app.use(echo.init());
// *-*-*-*-*-*-*-*-*-

// Handle Routes
app.get('/', (req, res) => {
  if (req.useragent && req.useragent.isDesktop) {
    res.sendFile(path.join(`${__dirname}/path/to/desktop/page`));
  } else if (req.useragent && req.useragent.isMobile) {
    res.sendFile(path.join(`${__dirname}/path/to/mobile/page`));
  }
});

server.listen(3000, () => {
  console.log('Listening on port 3000');
});

Available Functions

All of the Functions

License

To Kill

fluctus's People

Contributors

miblanchard avatar austinlyon avatar anwaukoni avatar mclaugmg avatar

Watchers

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