Sha256: 0efcf5ca6649c5d88b1c6ca7eebd21d8df2936c66f8bf71aa547b9e12e629d92
Contents?: true
Size: 798 Bytes
Versions: 2
Compression:
Stored size: 798 Bytes
Contents
module Jugglite class SseConnection attr_reader :body, :request def initialize(request) @request = request @body = DeferrableBody.new end def write(message, options = {}) buffer = "" options.each do |k, v| buffer << "#{k}: #{v}\n" end message.each_line do |line| buffer << "data: #{line.strip}\n" end @body.write(buffer << "\n") end def keepalive(extra=nil) # From http://dev.w3.org/html5/eventsource/#notes comment("keepalive #{extra}") end def comment(comment) @body.write(": #{comment}\n") end def close @body.succeed end def callback(&block) @body.callback(&block) end def errback(&block) @body.errback(&block) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jugglite-0.0.2.alpha | lib/jugglite/sse_connection.rb |
jugglite-0.0.1.alpha | lib/jugglite/sse_connection.rb |