{"_id":"jquery-sse","_rev":"9-30c571a65ad5408a6c89430f37bef6e6","name":"jquery-sse","description":"jQuery Plugin for Server-Sent Events (SSE) EventSource Polyfill","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.0":{"name":"jquery-sse","version":"0.1.0","description":"jQuery Plugin for Server-Sent Events (SSE) EventSource Polyfill","main":"jquery.sse.js","directories":{"example":"examples"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/byjg/jquery-sse.git"},"keywords":["jquery","jquery-plugin","server-sent","sse","eventsource"],"author":{"name":"João Gilberto Magalhães"},"license":"MIT","bugs":{"url":"https://github.com/byjg/jquery-sse/issues"},"gitHead":"e159c92273672f1caabdeafa6c084e08ef9625b5","homepage":"https://github.com/byjg/jquery-sse#readme","_id":"jquery-sse@0.1.0","_shasum":"dfa168047435c2807932ec03c7cdd8a8b2115147","_from":".","_npmVersion":"2.12.0","_nodeVersion":"0.10.25","_npmUser":{"name":"byjg","email":"joao@byjg.com.br"},"dist":{"shasum":"dfa168047435c2807932ec03c7cdd8a8b2115147","tarball":"https://registry.npmjs.org/jquery-sse/-/jquery-sse-0.1.0.tgz","integrity":"sha512-kCGYSN85loMkOu0GEknx4o+rJTkUzcKhlzlw+BoWEqZYm3hQfW9RhC2YKrSOdlaw6ZE0J6uVi/lRR8hoYJSM3Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC5V3WBfMECf96dsYa1/mJ0R8Px/a69Gg3s/wFx5q9MEAIhAI3qf4oZN2Wfc3iE57VpsfKiSIZ5X14T3Y7n4bim7GCs"}]},"maintainers":[{"name":"byjg","email":"joao@byjg.com.br"}]},"0.1.1":{"name":"jquery-sse","version":"0.1.1","description":"jQuery Plugin for Server-Sent Events (SSE) EventSource Polyfill","main":"jquery.sse.js","directories":{"example":"examples"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/byjg/jquery-sse.git"},"keywords":["jquery","jquery-plugin","server-sent events","sse","eventsource","event-source","polyfill"],"author":{"name":"João Gilberto Magalhães"},"license":"MIT","bugs":{"url":"https://github.com/byjg/jquery-sse/issues"},"dependencies":{"jquery":">=1.7.0"},"gitHead":"2892c22932f78f78d4c54506b95df750bbe3ac0b","homepage":"https://github.com/byjg/jquery-sse#readme","_id":"jquery-sse@0.1.1","_shasum":"793ad30198ebd0339a17d37915fcc57a5fe26c95","_from":".","_npmVersion":"2.12.0","_nodeVersion":"0.10.25","_npmUser":{"name":"byjg","email":"joao@byjg.com.br"},"dist":{"shasum":"793ad30198ebd0339a17d37915fcc57a5fe26c95","tarball":"https://registry.npmjs.org/jquery-sse/-/jquery-sse-0.1.1.tgz","integrity":"sha512-5oX/VqCDZ/ySr7IJTImT4cSVhM3shojZG6AwzL7ROyvU5hGLQnihDe80eU/bL30q+9YIuRAcluCBkDc4kSBcNg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC5NaWQhzX9vyidn8uzV+kUgHuKc8vvY8ZgGXQG312X4QIgcv4oJRgso0QwL9cJ3M9BKysJbYL3+3NXJ/YreJJtp5A="}]},"maintainers":[{"name":"byjg","email":"joao@byjg.com.br"}]},"0.1.2":{"name":"jquery-sse","version":"0.1.2","description":"jQuery Plugin for Server-Sent Events (SSE) EventSource Polyfill","main":"jquery.sse.js","directories":{"example":"examples"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/byjg/jquery-sse.git"},"keywords":["jquery","jquery-plugin","server-sent events","sse","eventsource","event-source","polyfill"],"author":{"name":"João Gilberto Magalhães"},"license":"MIT","bugs":{"url":"https://github.com/byjg/jquery-sse/issues"},"dependencies":{"jquery":">=1.7.0"},"gitHead":"d3b399d69b320e262fb02a4b7991aa0d1b550746","homepage":"https://github.com/byjg/jquery-sse#readme","_id":"jquery-sse@0.1.2","_shasum":"4d598934131b17c9fe28c8818d323841bd139807","_from":".","_npmVersion":"2.14.2","_nodeVersion":"4.0.0","_npmUser":{"name":"byjg","email":"joao@byjg.com.br"},"dist":{"shasum":"4d598934131b17c9fe28c8818d323841bd139807","tarball":"https://registry.npmjs.org/jquery-sse/-/jquery-sse-0.1.2.tgz","integrity":"sha512-ekC+YzwVTkiINXbRodQAaGnyoqd7SRgkVN+8M5jjq1PGq+WaEL+JT0yA+5LnHZIwKaAbcPPXpumjAtfZ+Y4CWQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC61TvSL8w/AkiPPaXSE686FakKL52V1QoPrnw4c6uDeQIgBEVpBEip+avl1iCEuZkuDvoOk43dw/+1VKZi12Aq7ns="}]},"maintainers":[{"name":"byjg","email":"joao@byjg.com.br"}]},"0.1.3":{"name":"jquery-sse","version":"0.1.3","description":"jQuery Plugin for Server-Sent Events (SSE) EventSource Polyfill","main":"jquery.sse.js","directories":{"example":"examples"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/byjg/jquery-sse.git"},"keywords":["jquery","jquery-plugin","server-sent events","sse","eventsource","event-source","polyfill"],"author":{"name":"João Gilberto Magalhães"},"license":"MIT","bugs":{"url":"https://github.com/byjg/jquery-sse/issues"},"dependencies":{"jquery":">=1.7.0"},"gitHead":"7c6722da8487a4cf7d3ffb55b69b39124ac35643","homepage":"https://github.com/byjg/jquery-sse#readme","_id":"jquery-sse@0.1.3","_shasum":"94af0b420d639231ba6d9106993aa3b6308bca59","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.7.0","_npmUser":{"name":"byjg","email":"joao@byjg.com.br"},"dist":{"shasum":"94af0b420d639231ba6d9106993aa3b6308bca59","tarball":"https://registry.npmjs.org/jquery-sse/-/jquery-sse-0.1.3.tgz","integrity":"sha512-35kDDJdFph16ipEc4dKNkTnppuXIjmW9nQvub7yZsqpWcJS51mlonQtIR4XROTQ/+tbfR9an5wYVxmv8QA4W8w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDc5z/R+WpUU1cAHAGv9D4mAgafmRz1wJkwBL+wMaRFFAIhANz2hDiKG11OUHbLRJ086xF3N70//hBIj2r57fVQgMXa"}]},"maintainers":[{"name":"byjg","email":"joao@byjg.com.br"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/jquery-sse-0.1.3.tgz_1465679786142_0.25382604426704347"}},"0.1.4":{"name":"jquery-sse","version":"0.1.4","description":"jQuery Plugin for Server-Sent Events (SSE) EventSource Polyfill","main":"jquery.sse.js","directories":{"example":"examples"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/byjg/jquery-sse.git"},"keywords":["jquery","jquery-plugin","server-sent events","sse","eventsource","event-source","polyfill"],"author":{"name":"João Gilberto Magalhães"},"license":"MIT","bugs":{"url":"https://github.com/byjg/jquery-sse/issues"},"dependencies":{"jquery":">=1.7.0"},"gitHead":"f82d67427db6b58e6848f8aa095c497ff210ec41","homepage":"https://github.com/byjg/jquery-sse#readme","_id":"jquery-sse@0.1.4","_shasum":"2a29c9b89027afd09da9fc50464ff90d2989fb43","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.9.0","_npmUser":{"name":"byjg","email":"joao@byjg.com.br"},"dist":{"shasum":"2a29c9b89027afd09da9fc50464ff90d2989fb43","tarball":"https://registry.npmjs.org/jquery-sse/-/jquery-sse-0.1.4.tgz","integrity":"sha512-wsgciBSCB5tSV5QTnU4lAuRhGh7fCu8wez7ry5Y/tonbRrUrRd3LKCaHqE8I1brLZgGeAaorIo7cCz/vv+0uig==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGUUnEmPUR/OBUp2P0psMI+l3fGZZcA9yoMdodnwi36XAiADZM2YzVGjWTQKRgK8y9H0449mS5yqroJLaVFWW5ShWQ=="}]},"maintainers":[{"name":"byjg","email":"joao@byjg.com.br"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/jquery-sse-0.1.4.tgz_1494963722842_0.3939607108477503"}},"0.1.5":{"name":"jquery-sse","version":"0.1.5","description":"jQuery Plugin for Server-Sent Events (SSE) EventSource Polyfill","main":"jquery.sse.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/byjg/jquery-sse.git"},"keywords":["jquery","jquery-plugin","server-sent events","sse","eventsource","event-source","polyfill"],"author":{"name":"João Gilberto Magalhães"},"license":"MIT","bugs":{"url":"https://github.com/byjg/jquery-sse/issues"},"dependencies":{"jquery":">=1.7.0"},"licenseText":"The MIT License (MIT)\n\nCopyright (c) 2017 Joao Gilberto Magalhaes\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"jquery-sse@0.1.5","dist":{"shasum":"264ff5dfb587339c25821536eeafa72cb4c5f9d1","integrity":"sha512-YOcUgFQ8nkeQguI/2PSSTVo1wLXehB+K76X4ll/vwNrGv722pbdA3p+umpcZ0Pn0D9+V2ByZVjkrCKn0QFNK/Q==","tarball":"https://registry.npmjs.org/jquery-sse/-/jquery-sse-0.1.5.tgz","fileCount":15,"unpackedSize":23292,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCmbH4Kgeym7R0UBkmBPSLLOhyOPayXD2g/rlPUYJzI0AIgQQpN+AKf0/Rg+pzYJ+BJUQvcuBwCtFWLP1sHyO4+UnM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiRnS4ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrUTRAAoIhJCM1E/9XmzYzdks1QZVAlqiJxFiCIVWMbaFL3Ou9g3w0z\r\nG9lnsgtR3KJfE4vl19RrnnQvJ1yR9XVOKkscqHyjrQAn7WQxxJHUMdpX+ouo\r\nQk3CrhfrlBNgKWBFLJ0AvbCrzwGeusR7Wg7DGCIWBipyH1mKMvjLEFunPlxo\r\nu0VvMfXfHQLypFMeEX0IyBeNfr1eivPWw/ev1tj7QjafSTEabCsxsN5jLQJB\r\nOhrejST4lPOFvaiwKwKj7GKKZL/emZRKRpw6cneEbQqzaINTUKl2/eiRMx2k\r\n3Kl4rELfWbkCIfr4W0iQ3dHsMppxUQVjsdcW0yC9uN8OmhUZmIQX17dsr2nk\r\n7ah5tmPwOP/xyysPW50hMfz7B8VPxmdHkku1uYjkMjmS8ph4Ahdk59/V63PC\r\nqwKbT+qoMZfB3MZ8DU9BZ1vX2Ge2BEBrvNiF2qWvGrnwuv9S1wQHekJ/30jw\r\nTakXYvuhsCA52X5syRs4Y1N2GDnZVXSu171XUWN2asHlHEQ7diwOrSXZVRZZ\r\niuimk6+2XTHMzVw6tvB7eM/icmcmMG+Ka4BBCJXE4EsNfbLaL8fIDzaKG5nr\r\nbDGW+cdTkW9bnELLUVzWinbqnhXb4/myzi1is7d+lBTUTmWz5TqWKVi6OCpU\r\nPtaZ9SC2RD4pJRcgxMMJggMy0TgBdyx3480=\r\n=ymIn\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"byjg","email":"joao@byjg.com.br"},"directories":{},"maintainers":[{"name":"byjg","email":"joao@byjg.com.br"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jquery-sse_0.1.5_1648784568498_0.5155516554340525"},"_hasShrinkwrap":false}},"readme":"# jQuery SSE\n\n[![Build Status](https://github.com/byjg/jquery-sse/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/byjg/jquery-sse/actions/workflows/build.yml)\n[![Opensource ByJG](https://img.shields.io/badge/opensource-byjg-success.svg)](http://opensource.byjg.com)\n[![GitHub source](https://img.shields.io/badge/Github-source-informational?logo=github)](https://github.com/byjg/jquery-sse/)\n[![GitHub license](https://img.shields.io/github/license/byjg/jquery-sse.svg)](https://opensource.byjg.com/opensource/licensing.html)\n[![GitHub release](https://img.shields.io/github/release/byjg/jquery-sse.svg)](https://github.com/byjg/jquery-sse/releases/)\n\nA lightweigth jQuery Plugin for Server-Sent Events (SSE) EventSource Polyfill. \nThis plugin try to use the native EventSource object if it supported by the browser.\nIf there is no native support the request is made by ajax requests (polling).\nYou do not need to change the server side nor the client side.\n\n*If you are looking for a SSE Polyfill library without jQuery dependency\ntry [yaj-sse](https://github.com/byjg/yaj-sse). The yaj-sse is a port\nfrom version 0.1.4 of jQuery SSE.*\n\n## Example\n\nClient Side\n\n```javascript\nvar sse = $.SSE('http://example.com/sse-server.php', {\n    onMessage: function(e){ \n        console.log(\"Message\"); console.log(e); \n    }\n});\nsse.start();\n```\n\nServer Side\n\n```php\necho \"data: My Message\\n\";\necho \"\\n\";\n```\n\n## Dependencies\n\n* jQuery\n\n## Install\n\nJust download the repository and point to the jQuery plugin:\n\n```html\n<script src=\"jquery.sse.js\" ></script>\n```\n\nor\n\n```html\n<script src=\"jquery.sse.min.js\" ></script>\n```\n\nYou can also install using bower:\n\n```bash\nbower install jquery-sse\n```\n\n## Usage:\n\n### Constructor\n\n```\nvar sse = $.SSE(url, settings);\n```\n\n* url: URL for the server will be sent the events to this page;\n* settings: The events and options for the SSE instance\n\n### Settings List\n\nAll the options:\n\n```\nvar sseObject = $.SSE('sse-server.php', {\n    onOpen: function (e) {},\n    onEnd: function (e) {},\n    onError: function (e) {},\n    onMessage: function (e) {},\n    options: {},\n    headers: {},\n    events: {}\n});\n```\n\n**Event onOpen**\n\nFired when the connection is opened the first time;\n\n```javascript\nonOpen: function(e){ \n    console.log(\"Open\"); console.log(e); \n},\n```\n\n**Event onEnd**\n\nFired when the connection is closed and the client will not listen for the server events;\n\n```javascript\nonEnd: function(e){ \n    console.log(\"End\"); console.log(e); \n},\n```\n\n**Event onError**\n\nFired when the connection error occurs;\n\n```javascript\nonError: function(e){ \n    console.log(\"Could not connect\"); \n},\n```\n\n**Event onMessage**\n\nFired when the a message without event is received\n\n```javascript\nonMessage: function(e){ \n    console.log(\"Message\"); console.log(e); \n},\n```\n\n**Custom Options**\n\nDefine the options for the SSE instance\n\n```javascript\noptions: {\n    forceAjax: false\n},\n```\n\n* **forceAjax**: Uses ajax even if the EventSource object is supported natively;\n\n\n**Custom Events**\n\nFired when the server set the event and match with the key\n\nFor example, if you have a custom event called `myEvent` you may use the follow code:\n\n```javascript\nevents: {\n    myEvent: function(e) {\n        console.log('Custom Event');\n        console.log(e);\n    }\n}\n```\n\nServer side:\n\n```php\necho \"event: myEvent\\n\";   // Must match with events in the HTML.\necho \"data: My Message\\n\";\necho \"\\n\";\n```\n\n**Custom Headers**\n\nYou can send custom headers to the request.\n\n```javascript\nheaders: {\n    'Authorization': 'Bearer 1a234fd4983d'\n}\n```\n\nNote: As the EventSource does not support send custom headers to the request,\nthe object will fallback automatically to 'forceAjax=true', even this it is not set.\n\n\n## Methods\n\n**start**\n\nStart the EventSource communication\n\n```javascript\nsse.start();\n```\n\n**stop**\n\nStop the EventSource communication\n\n```javascript\nsse.stop();\n```\n\n\n## Quirks\n\nThe ajax does not support the streaming as the event source supports. In that case we recommend\ncreate a server without streaming and set the \"retry\" to determine query frequency;\n\nExample Server Side:\n\n```php\necho \"retry: 3000\\n\";\necho \"data: My Message\\n\";\necho \"\\n\";\n```\n\n## Minify\n\n```\napt install uglifyjs\n\nuglifyjs --compress 'drop_console,drop_debugger' --mangle -r '$,require,exports,_' -o jquery.sse.min.js jquery.sse.js\n```\n\n## Running the examples\n\nStart the webserver:\n\n```shell\ndocker run -it --rm -p 8080:80 -v $PWD:/var/www/html byjg/php:7.4-fpm-nginx \n```\n\nOpen the browser:\nhttp://localhost:8080/examples/sse-client.html\n\n## References\n\n* http://www.w3.org/TR/2009/WD-eventsource-20091029/\n* https://developer.mozilla.org/en-US/docs/Server-sent_events/Using_server-sent_events\n* http://html5doctor.com/server-sent-events/\n* http://www.html5rocks.com/en/tutorials/eventsource/basics/\n\n----\n[Open source ByJG](http://opensource.byjg.com)\n","maintainers":[{"name":"byjg","email":"joao@byjg.com.br"}],"time":{"modified":"2022-06-19T05:12:54.120Z","created":"2015-06-30T20:36:59.520Z","0.1.0":"2015-06-30T20:36:59.520Z","0.1.1":"2015-07-12T03:52:19.330Z","0.1.2":"2015-09-28T21:32:45.809Z","0.1.3":"2016-06-11T21:16:28.823Z","0.1.4":"2017-05-16T19:42:03.096Z","0.1.5":"2022-04-01T03:42:48.693Z"},"keywords":["jquery","jquery-plugin","server-sent events","sse","eventsource","event-source","polyfill"],"repository":{"type":"git","url":"git://github.com/byjg/jquery-sse.git"},"author":{"name":"João Gilberto Magalhães"},"bugs":{"url":"https://github.com/byjg/jquery-sse/issues"},"license":"MIT","readmeFilename":"README.md","users":{"modestemax":true}}