{"id":21696030,"url":"https://github.com/francois2metz/em-eventsource","last_synced_at":"2025-04-06T09:10:21.485Z","repository":{"id":48771724,"uuid":"2141367","full_name":"francois2metz/em-eventsource","owner":"francois2metz","description":"em-eventsource is an eventmachine library to consume Server-Sent Events streaming API.","archived":false,"fork":false,"pushed_at":"2021-07-12T20:37:35.000Z","size":72,"stargazers_count":85,"open_issues_count":0,"forks_count":28,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-03-30T08:09:38.726Z","etag":null,"topics":["eventmachine","eventsource","eventsource-implementations","ruby","sse-client"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/francois2metz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-08-02T08:23:33.000Z","updated_at":"2024-05-21T07:38:19.000Z","dependencies_parsed_at":"2022-08-26T22:12:24.985Z","dependency_job_id":null,"html_url":"https://github.com/francois2metz/em-eventsource","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francois2metz%2Fem-eventsource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francois2metz%2Fem-eventsource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francois2metz%2Fem-eventsource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francois2metz%2Fem-eventsource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francois2metz","download_url":"https://codeload.github.com/francois2metz/em-eventsource/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457803,"owners_count":20941906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eventmachine","eventsource","eventsource-implementations","ruby","sse-client"],"created_at":"2024-11-25T19:18:06.495Z","updated_at":"2025-04-06T09:10:21.440Z","avatar_url":"https://github.com/francois2metz.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EventSource client for EventMachine\n\nSee the specification: https://html.spec.whatwg.org/multipage/server-sent-events.html\n\n## Install\n\nInstall with Rubygems:\n\n    gem install em-eventsource\n\nIf you use bundler, add it to your Gemfile:\n\n    gem \"em-eventsource\", \"~\u003e 0.3.0\"\n\n## Usage\n\nBasic usage:\n\n```ruby\nrequire \"em-eventsource\"\nEM.run do\n  source = EventMachine::EventSource.new(\"http://example.com/streaming\")\n  source.message do |message|\n    puts \"new message #{message}\"\n  end\n  source.start # Start listening\nend\n```\n\nListening specific event name:\n\n```ruby\nsource.on \"eventname\" do |message|\n  puts \"eventname #{message}\"\nend\n```\n\nHandle error:\n\n```ruby\nsource.error do |error|\n  puts \"error #{error}\"\nend\n```\n\nHandle open stream:\n\n```ruby\nsource.open do\n  puts \"opened\"\nend\n```\n\nClose the stream:\n\n```ruby\nsource.close\n```\n\nCurrent status of the connection:\n\n```ruby\n# Can be:\n# - EM::EventSource::CLOSED\n# - EM::EventSource::CONNECTING\n# - EM::EventSource::OPEN\nsource.ready_state\n```\n\nOverride the default retry value (if the connection is lost):\n\n```ruby\nsource.retry = 5 # in seconds (default 3)\n```\n\nGet Last-Event-Id value:\n\n```ruby\nsource.last_event_id\n```\n\nAttach middleware:\n\n```ruby\nsource.use EM::Middleware::JSONResponse\n```\n\nSet the inactivity timeout. Set to 0 to disable the timeout.\n\n```ruby\nsource.inactivity_timeout = 120 # in seconds (default: 60).\n```\n\n## Licence\n\nMIT License\n\nCopyright (C) 2020 François de Metz\n\nCopyright (C) 2011 af83\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancois2metz%2Fem-eventsource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancois2metz%2Fem-eventsource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancois2metz%2Fem-eventsource/lists"}