Skip to content

fabricematrat/BrowserPush

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BrowserPush Cordova Plugin

Event Source and WebSocket are not implemented in the Android browser. This cordova plugin allows the usage of SSE (EventSource) and WebSocket for hybrid application.

For EventSource the implementation should be compliant with the specification http://www.w3.org/TR/2012/WD-eventsource-20121023/

Prerequisite

Install

If you use Cordova command line interface :

  • Create an application
cordova create YourApplication
  • Add an Android platform
cd YourApplication
cordova platform add android
  • Add the plugin
// You should be able to do that with plugman but this does not work
// cordova plugin add https://github.com/fabricematrat/BrowserPush.git
// So you will have to clone the BrowserPush plugin
// git clone https://github.com/fabricematrat/BrowserPush.git at $pluginLocation (not inside the project)
cordova plugin add $pluginLocation
  • Bug in some version of the command line interface
cp -f plugins/BrowserPush/www/browserpush.js www/browserpush.js
  • Include a reference to browserpush.js in your index.html located in the www directory after cordova.js
  <script type="text/javascript" src="cordova.js"></script>
  <script type="text/javascript" src="browserpush.js"></script>
  • For a small test, add in your js/index.js an EventSource in the deviceready callback the following:
var source = new EventSource('http://googlecodesamples.com/html5/sse/sse.php');
source.addEventListener('message', function(event) {
  alert(event.data);
}, false);

You will connect a test server wich send sever sent event. This will pop an alert like in the following documentation : http://googlecodesamples.com/html5/sse/sse.html

  • Build your project
cordova build
  • Start the emulator (You need to have an AVD created)
cordova emulate

Run integration test

Go to itest where you will have an integration test itest.sh will create a cordova project, launch it in an emulator. The project itself will test the EventSource with tests influenced by https://github.com/w3c/web-platform-tests/tree/master/eventsource

TODO

Finish the implementation of Event source

  • Redirection
  • Credentails
  • Test https
  • Test Thread Safety
  • Test Performance

Finish the implementation of WebSocket

  • Only the java part is done
  • Need to continue to work on it to be usable.

RELEASE NOTES

20130526

  • Initial Version

Give it a trial and send us feedback!

3musket33rs on twitter @3musket33rs

  • Athos is Corinne Krych (@corinnekrych)
  • Aramis is Sebastien Blanc (@sebi2706)
  • Porthos is Fabrice Matrat (@fabricematrat)
  • D'artagnain is Mathieu Bruyen (@mathbruyen)

About

Cordova plugin for SSE and WebSocket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published