Sha256: 64bdc3255d9c9a3cd54b9582c51d6c857fd436994ea14a186eaae29c28a1c994
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require "uri" require "server_sent_events/version" require "server_sent_events/client" require "server_sent_events/parser" module ServerSentEvents # Convenience method to get up-and-running fast. # # In order to start listening to server events, this is all the code that we # need: # # ServerSentEvents.listen("http://example.com") do |event| # puts event # end # # @param address [String, URI] SSE endpoint # @param headers [Hash] HTTP headers to use when connecting # @param callback code block that should be executed on event arrival def self.listen(address, headers = {}, &callback) create_client(address, headers).listen(&callback) end # Create new client that uses default parser to parse events. # # @param address [String, URI] SSE endpoint # @param headers [Hash] HTTP headers to use when connecting # @return [Client] client def self.create_client(address, headers = {}) Client.new(URI(address), Parser.new, headers) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
server_sent_events-0.1.3 | lib/server_sent_events.rb |
server_sent_events-0.1.2 | lib/server_sent_events.rb |