Class: Subscriber::MultiparMixedClient
- Inherits:
-
LongPollClient
- Object
- Client
- LongPollClient
- Subscriber::MultiparMixedClient
- Includes:
- Celluloid::IO
- Defined in:
- lib/nchan_tools/pubsub.rb
Defined Under Namespace
Classes: MultipartMixedParser
Instance Attribute Summary
Attributes inherited from LongPollClient
Attributes inherited from Client
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from LongPollClient
#close, #error, #initialize, #listen, #request_code_ok, #run, #stop
Methods inherited from Client
#error, #handle_bundle_error, inherited, #initialize, lookup, #poke, #provides_msgid?, #run, #stop, unique_aliases
Constructor Details
This class inherits a constructor from Subscriber::LongPollClient
Class Method Details
.aliases ⇒ Object
1298 1299 1300 |
# File 'lib/nchan_tools/pubsub.rb', line 1298 def self.aliases [:multipart, :multipartmixed, :mixed] end |
Instance Method Details
#new_bundle(uri, opt) ⇒ Object
1362 1363 1364 1365 |
# File 'lib/nchan_tools/pubsub.rb', line 1362 def new_bundle(uri, opt) opt[:accept]="multipart/mixed" super end |
#setup_bundle(b) ⇒ Object
1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 |
# File 'lib/nchan_tools/pubsub.rb', line 1367 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, | @timer.reset if @timer unless @nomsg @timer.reset if @timer msg=Message.new .dup, headers["Last-Modified"], headers["Etag"] msg.content_type=headers["Content-Type"] else msg= end if @subscriber.(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 |