Gathering detailed insights and metrics for jquery-sse
Gathering detailed insights and metrics for jquery-sse
Gathering detailed insights and metrics for jquery-sse
Gathering detailed insights and metrics for jquery-sse
graphql-sse
Zero-dependency, HTTP/1 safe, simple, GraphQL over Server-Sent Events Protocol server and client
eventsource
W3C compliant EventSource client for Node.js and browser (polyfill)
launchdarkly-eventsource
Fork of eventsource package - W3C compliant EventSource client for Node.js and browser (polyfill)
graphql-ws
Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client
npm install jquery-sse
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
52 Stars
40 Commits
18 Forks
6 Watching
1 Branches
2 Contributors
Updated on 02 Aug 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-33.3%
8
Compared to previous day
Last week
-31.1%
31
Compared to previous week
Last month
97.5%
241
Compared to previous month
Last year
8.6%
1,524
Compared to previous year
1
A lightweigth jQuery Plugin for Server-Sent Events (SSE) EventSource Polyfill. This plugin try to use the native EventSource object if it supported by the browser. If there is no native support the request is made by ajax requests (polling). You do not need to change the server side nor the client side.
If you are looking for a SSE Polyfill library without jQuery dependency try yaj-sse. The yaj-sse is a port from version 0.1.4 of jQuery SSE.
Client Side
1var sse = $.SSE('http://example.com/sse-server.php', { 2 onMessage: function(e){ 3 console.log("Message"); console.log(e); 4 } 5}); 6sse.start();
Server Side
1echo "data: My Message\n"; 2echo "\n";
Just download the repository and point to the jQuery plugin:
1<script src="jquery.sse.js" ></script>
or
1<script src="jquery.sse.min.js" ></script>
You can also install using bower:
1bower install jquery-sse
var sse = $.SSE(url, settings);
All the options:
var sseObject = $.SSE('sse-server.php', {
onOpen: function (e) {},
onEnd: function (e) {},
onError: function (e) {},
onMessage: function (e) {},
options: {},
headers: {},
events: {}
});
Event onOpen
Fired when the connection is opened the first time;
1onOpen: function(e){ 2 console.log("Open"); console.log(e); 3},
Event onEnd
Fired when the connection is closed and the client will not listen for the server events;
1onEnd: function(e){ 2 console.log("End"); console.log(e); 3},
Event onError
Fired when the connection error occurs;
1onError: function(e){ 2 console.log("Could not connect"); 3},
Event onMessage
Fired when the a message without event is received
1onMessage: function(e){ 2 console.log("Message"); console.log(e); 3},
Custom Options
Define the options for the SSE instance
1options: { 2 forceAjax: false 3},
Custom Events
Fired when the server set the event and match with the key
For example, if you have a custom event called myEvent
you may use the follow code:
1events: { 2 myEvent: function(e) { 3 console.log('Custom Event'); 4 console.log(e); 5 } 6}
Server side:
1echo "event: myEvent\n"; // Must match with events in the HTML. 2echo "data: My Message\n"; 3echo "\n";
Custom Headers
You can send custom headers to the request.
1headers: { 2 'Authorization': 'Bearer 1a234fd4983d' 3}
Note: As the EventSource does not support send custom headers to the request, the object will fallback automatically to 'forceAjax=true', even this it is not set.
start
Start the EventSource communication
1sse.start();
stop
Stop the EventSource communication
1sse.stop();
The ajax does not support the streaming as the event source supports. In that case we recommend create a server without streaming and set the "retry" to determine query frequency;
Example Server Side:
1echo "retry: 3000\n"; 2echo "data: My Message\n"; 3echo "\n";
apt install uglifyjs
uglifyjs --compress 'drop_console,drop_debugger' --mangle -r '$,require,exports,_' -o jquery.sse.min.js jquery.sse.js
Start the webserver:
1docker run -it --rm -p 8080:80 -v $PWD:/var/www/html byjg/php:7.4-fpm-nginx
Open the browser: http://localhost:8080/examples/sse-client.html
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/23 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More