Class: DockerCloud::StreamAPI
- Defined in:
- lib/docker_cloud/api/stream_api.rb
Direct Known Subclasses
Constant Summary collapse
- STREAM_API_PATH =
'wss://ws.cloud.docker.com/api'.freeze
Constants inherited from API
API::API_VERSION, API::BASE_API_PATH
Instance Attribute Summary
Attributes inherited from API
Instance Method Summary collapse
Methods inherited from API
#get_from_uri, #http_delete, #http_get, #http_patch, #http_post, #initialize, #parse, #url
Constructor Details
This class inherits a constructor from DockerCloud::API
Instance Method Details
#on(type, &block) ⇒ Object
12 13 14 15 |
# File 'lib/docker_cloud/api/stream_api.rb', line 12 def on(type, &block) @listeners = {} unless @listeners @listeners[type.to_sym] = block end |
#run!(&block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/docker_cloud/api/stream_api.rb', line 17 def run!(&block) EventMachine.kqueue = true if EventMachine.kqueue? EM.run { @shutting_down = false Signal.trap('INT') { signal_handler('INT') } Signal.trap('TERM') { signal_handler('TERM') } if block_given? block.call end connect } end |
#websocket ⇒ Object
5 6 7 8 9 10 |
# File 'lib/docker_cloud/api/stream_api.rb', line 5 def websocket @websocket ||= begin url = URI.escape(STREAM_API_PATH + '/' + root_path + '/' + API_VERSION + websocket_path) Faye::WebSocket::Client.new(url, nil, ping: 240, headers: headers) end end |