class NchanTools::Subscriber::MultiparMixedClient
Public Class Methods
aliases()
click to toggle source
# File lib/nchan_tools/pubsub.rb, line 1297 def self.aliases [:multipart, :multipartmixed, :mixed] end
Public Instance Methods
new_bundle(uri, opt)
click to toggle source
Calls superclass method
NchanTools::Subscriber::LongPollClient#new_bundle
# File lib/nchan_tools/pubsub.rb, line 1361 def new_bundle(uri, opt) opt[:accept]="multipart/mixed" super end
setup_bundle(b)
click to toggle source
Calls superclass method
NchanTools::Subscriber::LongPollClient#setup_bundle
# File lib/nchan_tools/pubsub.rb, line 1366 def setup_bundle b super b.on_headers do |code, headers| if code == 200 b.connected = true @notready -= 1 @cooked_ready.signal true if @notready == 0 b.subparser = MultipartMixedParser.new headers["Content-Type"] b.subparser.on_part do |headers, message| @timer.reset if @timer unless @nomsg @timer.reset if @timer msg=Message.new message.dup, headers["Last-Modified"], headers["Etag"] msg.content_type=headers["Content-Type"] else msg=message end if @subscriber.on_message(msg, b) == false @subscriber.finished+=1 close b end end b.subparser.on_finish do b.subparser.finished = true end else #puts "BUFFER THE BODY" #b.buffer_body! end end b.on_chunk do |chunk| if b.subparser b.subparser << chunk if HTTPBundle === b && b.subparser.finished @subscriber.on_failure error(410, "Server Closed Connection", b) @subscriber.finished+=1 close b end end end b.on_response do |code, headers, body| if !b.subparser @subscriber.on_failure error(code, "", b) elsif b.subparser.finished @subscriber.on_failure error(410, "Server Closed Connection", b) else @subscriber.on_failure error(0, "Response completed unexpectedly", b) end @subscriber.finished+=1 close b end end