Skip to content
Kward Search API index

Class: Kward::Transport::Host::Turn

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/transport/host.rb

Overview

Handle for an asynchronously running Kward turn.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, handle, actor) ⇒ Turn

Returns a new instance of Turn.



298
299
300
301
302
303
# File 'lib/kward/transport/host.rb', line 298

def initialize(host, handle, actor)
  @host = host
  @actor = actor
  @id = handle.id.to_s.freeze
  @session_id = handle.session_id.to_s.freeze
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



296
297
298
# File 'lib/kward/transport/host.rb', line 296

def id
  @id
end

#session_idObject (readonly)

Returns the value of attribute session_id.



296
297
298
# File 'lib/kward/transport/host.rb', line 296

def session_id
  @session_id
end

Instance Method Details

#cancelObject



319
320
321
322
# File 'lib/kward/transport/host.rb', line 319

def cancel
  @host.authorize!(:cancel_turn, actor: @actor, session_id: @session_id, turn_id: @id)
  @host.gateway.cancel_transport_turn(turn_id: @id)
end

#events(after: nil) ⇒ Object



311
312
313
# File 'lib/kward/transport/host.rb', line 311

def events(after: nil)
  @host.gateway.transport_turn_events(turn_id: @id, after: after)
end

#statusObject



315
316
317
# File 'lib/kward/transport/host.rb', line 315

def status
  @host.gateway.transport_turn_status(turn_id: @id)
end

#subscribe(after: nil, &block) ⇒ Object

Raises:

  • (ArgumentError)


305
306
307
308
309
# File 'lib/kward/transport/host.rb', line 305

def subscribe(after: nil, &block)
  raise ArgumentError, "turn subscription requires a block" unless block

  @host.gateway.subscribe_transport_turn(turn_id: @id, after: after, &block)
end