SlideShare a Scribd company logo
1 of 9
Download to read offline
Control USB Device
from Rails App.
by using WebSocket
Rubyist Meetup 0.0.3
26/07/2014
Katsuyuki Koga (Class K)
Open Cash Drawer when user push
submit button in register Web application
USB
Windows PC
Cash Drawer
My Web App. runs on Browser
My Web App.
also run
on Safari/iPad
Approach
• Use Bluetooth between Native iOS
App and Proprietary HW
• Native Module as Chrome Extension
• NPAPI, PAPPI, NaCl Socket API
• WebSocket Server and Native client
competitor s
my first
my current
Windows PC
USB
Windows EXE program
(Open Cash Drawer)
Ruby script - HTTP client
My Rails App.
running on Heroku
Pusher AddOn
Call API
WebSocket
GET
Solution Overview
Windows PC
USB
Windows EXE program
(Open Cash Drawer)
Ruby script - HTTP client
My Rails App.
running on Heroku
Pusher AddOn
Call API
WebSocket
GET
event_name = = 'open cash drawer'
Pusher[channel].trigger(event_name, {
message: 'open',
cash_drawer_id: cashdrawer_id
})
Windows PC
USB
Windows EXE program
(Open Cash Drawer)
Ruby script - HTTP client
My Rails App.
running on Heroku
Pusher AddOn
Call API
WebSocket
GET
- Open WebSocket channel
- Kick Windows EXE when event received
require 'pusher-client'
EVENT_NAME = 'open cash drawer'
COMMAND_LINE = '************.EXE **** *****'
channel = "C%d" % COMPANY_ID
options = {:secret => '60978c770***********'}
socket = PusherClient::Socket.new('1***********e17b****1', options)
socket.subscribe(channel, CASHDRAWER_ID)
socket[channel].bind(EVENT_NAME) do ¦data¦
data = JSON.parse data, { symbolize_names: true }
if CASHDRAWER_ID == data[:cash_drawer_id]
system(COMMAND_LINE)
end
end
socket.connect
Windows PC
USB
Windows EXE program
(Open Cash Drawer)
Ruby script - HTTP client
My Rails App.
running on Heroku
Pusher AddOn
Call API
WebSocket
GET
Solution Overview
Conclusion
• Now, cost/effort of using WebSocket is
very small for RoR/Web App. developers
• Pusher is free up to 5,000 msgs/month
• Heroku just announced to release
WebSocket addon on 07/07/2014
• https://devcenter.heroku.com/articles/websockets
• Web App. + REAL device can be more
smart solution / experience

More Related Content

What's hot

Inspiring conference - Automation & external service integration
Inspiring conference -  Automation & external service integrationInspiring conference -  Automation & external service integration
Inspiring conference - Automation & external service integrationdfeyer
 
Jaggery Introductory Webinar
Jaggery Introductory WebinarJaggery Introductory Webinar
Jaggery Introductory WebinarNuwan Bandara
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkitPaul Jensen
 
Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)
Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)
Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)Eddie Lau
 
JJUG - ActionScript3のススメ
JJUG - ActionScript3のススメJJUG - ActionScript3のススメ
JJUG - ActionScript3のススメSeacolor
 
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...Les-Tilleuls.coop
 
WordPress REST API v2: Overview & Exploring
WordPress REST API v2: Overview & ExploringWordPress REST API v2: Overview & Exploring
WordPress REST API v2: Overview & ExploringNick Pelton
 
Real World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker CachingReal World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker CachingChris Love
 
Creating SmartPhone Apps Using WordPress
Creating SmartPhone Apps Using WordPressCreating SmartPhone Apps Using WordPress
Creating SmartPhone Apps Using WordPresscodebangla
 
Official "push" and real-time capabilities for Symfony and API Platform (Merc...
Official "push" and real-time capabilities for Symfony and API Platform (Merc...Official "push" and real-time capabilities for Symfony and API Platform (Merc...
Official "push" and real-time capabilities for Symfony and API Platform (Merc...Les-Tilleuls.coop
 
Using Minikube for Node.js development
Using Minikube for Node.js developmentUsing Minikube for Node.js development
Using Minikube for Node.js developmentTroy Connor
 
Panther: test your Symfony apps with real web browsers
Panther: test your Symfony apps with real web browsersPanther: test your Symfony apps with real web browsers
Panther: test your Symfony apps with real web browsersLes-Tilleuls.coop
 
Using Firebug & YSlow
Using Firebug & YSlowUsing Firebug & YSlow
Using Firebug & YSlowBrad Vernon
 
Object-Oriented Programming & Ruby
Object-Oriented Programming & RubyObject-Oriented Programming & Ruby
Object-Oriented Programming & RubyAmine Sadry
 
Making Magic with WP-CLI
Making Magic with WP-CLIMaking Magic with WP-CLI
Making Magic with WP-CLIryanduff
 
How to Develop a Distributed App on Ethereum
How to Develop a Distributed App on EthereumHow to Develop a Distributed App on Ethereum
How to Develop a Distributed App on EthereumMarco Ottolini
 

What's hot (20)

Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
Inspiring conference - Automation & external service integration
Inspiring conference -  Automation & external service integrationInspiring conference -  Automation & external service integration
Inspiring conference - Automation & external service integration
 
Jaggery Introductory Webinar
Jaggery Introductory WebinarJaggery Introductory Webinar
Jaggery Introductory Webinar
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkit
 
Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)
Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)
Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)
 
JJUG - ActionScript3のススメ
JJUG - ActionScript3のススメJJUG - ActionScript3のススメ
JJUG - ActionScript3のススメ
 
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...
HTTP/2: speed up your apps and dispatch real time updates (Symfony and API Pl...
 
WordPress REST API v2: Overview & Exploring
WordPress REST API v2: Overview & ExploringWordPress REST API v2: Overview & Exploring
WordPress REST API v2: Overview & Exploring
 
Html 5 boot camp
Html 5 boot campHtml 5 boot camp
Html 5 boot camp
 
Real World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker CachingReal World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker Caching
 
GreenButton-201502
GreenButton-201502GreenButton-201502
GreenButton-201502
 
Creating SmartPhone Apps Using WordPress
Creating SmartPhone Apps Using WordPressCreating SmartPhone Apps Using WordPress
Creating SmartPhone Apps Using WordPress
 
Official "push" and real-time capabilities for Symfony and API Platform (Merc...
Official "push" and real-time capabilities for Symfony and API Platform (Merc...Official "push" and real-time capabilities for Symfony and API Platform (Merc...
Official "push" and real-time capabilities for Symfony and API Platform (Merc...
 
Using Minikube for Node.js development
Using Minikube for Node.js developmentUsing Minikube for Node.js development
Using Minikube for Node.js development
 
Panther: test your Symfony apps with real web browsers
Panther: test your Symfony apps with real web browsersPanther: test your Symfony apps with real web browsers
Panther: test your Symfony apps with real web browsers
 
Using Firebug & YSlow
Using Firebug & YSlowUsing Firebug & YSlow
Using Firebug & YSlow
 
Object-Oriented Programming & Ruby
Object-Oriented Programming & RubyObject-Oriented Programming & Ruby
Object-Oriented Programming & Ruby
 
Making Magic with WP-CLI
Making Magic with WP-CLIMaking Magic with WP-CLI
Making Magic with WP-CLI
 
How to Develop a Distributed App on Ethereum
How to Develop a Distributed App on EthereumHow to Develop a Distributed App on Ethereum
How to Develop a Distributed App on Ethereum
 
Firebase slide
Firebase slideFirebase slide
Firebase slide
 

Similar to Control USB Device from Rails App. by using WebSocket

Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsYakov Fain
 
FEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoFEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoCaridy Patino
 
Design Patterns for Smart Applications
Design Patterns for Smart ApplicationsDesign Patterns for Smart Applications
Design Patterns for Smart ApplicationsSri Ambati
 
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R..."Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...Fwdays
 
Data Visualization: Introduction to Shiny Web Applications
Data Visualization: Introduction to Shiny Web ApplicationsData Visualization: Introduction to Shiny Web Applications
Data Visualization: Introduction to Shiny Web ApplicationsOlga Scrivner
 
OpenWhisk Under the Hood -- London Oct 16 2016
OpenWhisk Under the Hood -- London Oct 16 2016OpenWhisk Under the Hood -- London Oct 16 2016
OpenWhisk Under the Hood -- London Oct 16 2016Stephen Fink
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - MozillaRobert Nyman
 
LDC Via building a new app
LDC Via  building a new appLDC Via  building a new app
LDC Via building a new appMark Myers
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonRobert Nyman
 
Windows Phone 8 - 12 Network Communication
Windows Phone 8 - 12 Network CommunicationWindows Phone 8 - 12 Network Communication
Windows Phone 8 - 12 Network CommunicationOliver Scheer
 
NCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsNCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsJohn M. Wargo
 
Serverless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhiskServerless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhiskDaniel Krook
 
(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS UniverseStefano Di Paola
 
Introduction to Progressive web app (PWA)
Introduction to Progressive web app (PWA)Introduction to Progressive web app (PWA)
Introduction to Progressive web app (PWA)Zhentian Wan
 
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Amazon Web Services
 
Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyUlrich Krause
 
Why progressive apps for WordPress - WordSesh 2020
Why progressive apps for WordPress - WordSesh 2020Why progressive apps for WordPress - WordSesh 2020
Why progressive apps for WordPress - WordSesh 2020Imran Sayed
 
Containerizing your Security Operations Center
Containerizing your Security Operations CenterContainerizing your Security Operations Center
Containerizing your Security Operations CenterJimmy Mesta
 

Similar to Control USB Device from Rails App. by using WebSocket (20)

Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
 
FEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoFEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing Mojito
 
Always on! ... or not?
Always on! ... or not?Always on! ... or not?
Always on! ... or not?
 
Design Patterns for Smart Applications
Design Patterns for Smart ApplicationsDesign Patterns for Smart Applications
Design Patterns for Smart Applications
 
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R..."Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
 
Data Visualization: Introduction to Shiny Web Applications
Data Visualization: Introduction to Shiny Web ApplicationsData Visualization: Introduction to Shiny Web Applications
Data Visualization: Introduction to Shiny Web Applications
 
OpenWhisk Under the Hood -- London Oct 16 2016
OpenWhisk Under the Hood -- London Oct 16 2016OpenWhisk Under the Hood -- London Oct 16 2016
OpenWhisk Under the Hood -- London Oct 16 2016
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 
LDC Via building a new app
LDC Via  building a new appLDC Via  building a new app
LDC Via building a new app
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
 
Windows Phone 8 - 12 Network Communication
Windows Phone 8 - 12 Network CommunicationWindows Phone 8 - 12 Network Communication
Windows Phone 8 - 12 Network Communication
 
Always on! Or not?
Always on! Or not?Always on! Or not?
Always on! Or not?
 
NCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsNCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile Apps
 
Serverless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhiskServerless APIs with Apache OpenWhisk
Serverless APIs with Apache OpenWhisk
 
(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe
 
Introduction to Progressive web app (PWA)
Introduction to Progressive web app (PWA)Introduction to Progressive web app (PWA)
Introduction to Progressive web app (PWA)
 
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
 
Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easy
 
Why progressive apps for WordPress - WordSesh 2020
Why progressive apps for WordPress - WordSesh 2020Why progressive apps for WordPress - WordSesh 2020
Why progressive apps for WordPress - WordSesh 2020
 
Containerizing your Security Operations Center
Containerizing your Security Operations CenterContainerizing your Security Operations Center
Containerizing your Security Operations Center
 

Control USB Device from Rails App. by using WebSocket

  • 1. Control USB Device from Rails App. by using WebSocket Rubyist Meetup 0.0.3 26/07/2014 Katsuyuki Koga (Class K)
  • 2. Open Cash Drawer when user push submit button in register Web application USB Windows PC Cash Drawer My Web App. runs on Browser My Web App. also run on Safari/iPad
  • 3. Approach • Use Bluetooth between Native iOS App and Proprietary HW • Native Module as Chrome Extension • NPAPI, PAPPI, NaCl Socket API • WebSocket Server and Native client competitor s my first my current
  • 4. Windows PC USB Windows EXE program (Open Cash Drawer) Ruby script - HTTP client My Rails App. running on Heroku Pusher AddOn Call API WebSocket GET Solution Overview
  • 5. Windows PC USB Windows EXE program (Open Cash Drawer) Ruby script - HTTP client My Rails App. running on Heroku Pusher AddOn Call API WebSocket GET event_name = = 'open cash drawer' Pusher[channel].trigger(event_name, { message: 'open', cash_drawer_id: cashdrawer_id })
  • 6. Windows PC USB Windows EXE program (Open Cash Drawer) Ruby script - HTTP client My Rails App. running on Heroku Pusher AddOn Call API WebSocket GET - Open WebSocket channel - Kick Windows EXE when event received
  • 7. require 'pusher-client' EVENT_NAME = 'open cash drawer' COMMAND_LINE = '************.EXE **** *****' channel = "C%d" % COMPANY_ID options = {:secret => '60978c770***********'} socket = PusherClient::Socket.new('1***********e17b****1', options) socket.subscribe(channel, CASHDRAWER_ID) socket[channel].bind(EVENT_NAME) do ¦data¦ data = JSON.parse data, { symbolize_names: true } if CASHDRAWER_ID == data[:cash_drawer_id] system(COMMAND_LINE) end end socket.connect
  • 8. Windows PC USB Windows EXE program (Open Cash Drawer) Ruby script - HTTP client My Rails App. running on Heroku Pusher AddOn Call API WebSocket GET Solution Overview
  • 9. Conclusion • Now, cost/effort of using WebSocket is very small for RoR/Web App. developers • Pusher is free up to 5,000 msgs/month • Heroku just announced to release WebSocket addon on 07/07/2014 • https://devcenter.heroku.com/articles/websockets • Web App. + REAL device can be more smart solution / experience