Class: Mycel::Channel::Command

Inherits:
Context
  • Object
show all
Includes:
Mycel::Callbacks
Defined in:
lib/mycel.rb

Constant Summary

Constants inherited from Context

Mycel::Channel::Context::STATE_INIT, Mycel::Channel::Context::STATE_RUNNING, Mycel::Channel::Context::STATE_STOPPED

Instance Method Summary collapse

Methods included from Mycel::Callbacks

#__mycel_callback_handlers__, #callback, #on

Methods inherited from Context

#wait

Constructor Details

#initialize(session) ⇒ Command

Returns a new instance of Command.



412
413
414
415
# File 'lib/mycel.rb', line 412

def initialize(session)
  super
  @id = @session.generate_and_register_out_id(self)
end

Instance Method Details

#advise(payload) ⇒ Object



424
425
426
427
428
# File 'lib/mycel.rb', line 424

def advise(payload)
  guard_assert_state(STATE_RUNNING) {
    @session.send(Message.generate_payload_msg('advise', @id, payload))
  }
end

#request(payload) ⇒ Object



417
418
419
420
421
422
# File 'lib/mycel.rb', line 417

def request(payload)
  guard_assert_state(STATE_INIT) {
    @session.send(Message.generate_payload_msg('request', @id, payload))
    change_state(STATE_RUNNING)
  }
end

#they_abortObject



438
439
440
441
442
443
444
# File 'lib/mycel.rb', line 438

def they_abort
  guard_assert_state(STATE_RUNNING) {
    callback(:abort)
    @session.unregister_id(DIR_COMMAND, @id)
    change_state(STATE_STOPPED)
  }
end

#they_progress(payload) ⇒ Object



446
447
448
449
450
# File 'lib/mycel.rb', line 446

def they_progress(payload)
  guard_assert_state(STATE_RUNNING) {
    callback(:progress, payload)
  }
end

#they_respond(payload) ⇒ Object



430
431
432
433
434
435
436
# File 'lib/mycel.rb', line 430

def they_respond(payload)
  guard_assert_state(STATE_RUNNING) {
    callback(:response, payload)
    @session.unregister_id(DIR_COMMAND, @id)
    change_state(STATE_STOPPED)
  }
end