Skip to content

andregrillo/cordova-plugin-sse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova Plugin SSE

This is a Cordova plugin for Server-Sent Events (SSE). It provides an interface for opening and closing an SSE connection on both iOS and Android platforms.

Installation

To install the plugin, use the following command:

cordova plugin add https://github.com/andregrillo/cordova-plugin-sse.git

Usage

The plugin provides two methods: startEventSource and stopEventSource.

startEventSource

This method opens an SSE connection to a specified URL. It takes a URL as a parameter and two callbacks for success and error.

cordova.plugins.sse.startEventSource(successCallback, errorCallback, url);

stopEventSource

This method closes the SSE connection. It takes two callbacks for success and error.

cordova.plugins.sse.stopEventSource(successCallback, errorCallback);

Example

// Start SSE connection
cordova.plugins.sse.startEventSource(
  function(message) {
    console.log("SSE message received: ", message);
  },
  function(error) {
    console.error("Error occurred: ", error);
  },
  "https://example.com/sse"
);

// Stop SSE connection
cordova.plugins.sse.stopEventSource(
  function(message) {
    console.log("SSE connection closed: ", message);
  },
  function(error) {
    console.error("Error occurred: ", error);
  }
);

Author

André Grillo - OutSystems

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published