lib/datalackeylib.rb
# Pass nil pattern_action if you are not interested in doing anything.
Pass nil pattern_action if you are not interested in doing anything.
Pass nil pattern_action if you are not interested in doing anything .
def send(pattern_action, command, user_id = false)
    return nil if @to_datalackey_mutex.synchronize { @to_datalackey.closed? }
    if user_id
      id = command[0]
    else
      id = @identifier
      @identifier += 1
      command.prepend id
    end
    tracker = pattern_action.nil? ? NoPatternNoAction.new : pattern_action.clone
    tracker.set_identifier(id)
    tracker.command = JSON.generate(command)
    internal = @internal.clone
    internal.set_identifier(id)
    @tracked_mutex.synchronize do
      @tracked[id] = [ tracker, internal ] unless id.nil?
      @waiting = id
    end
    dump(tracker.command)
    return tracker if id.nil? 
    @return_mutex.synchronize { @return_condition.wait(@return_mutex) }
    tracker.status = true
    unless tracker.exit.nil?
      tracker.exit.each do |item|
        tracker.status = false if item.first == :error || item.first == 'error'
      end
    end
    tracker
  end
def send ( pattern_action , command , user_id = false ) return nil if @to_datalackey_mutex . synchronize { @to_datalackey . closed? } if user_id id = command [ 0 ] else id = @identifier @identifier += 1 command . prepend id end tracker = pattern_action . nil? ? NoPatternNoAction . new : pattern_action . clone tracker . set_identifier ( id ) tracker . command = JSON . generate ( command ) internal = @internal . clone internal . set_identifier ( id ) @tracked_mutex . synchronize do @tracked [ id ] = [ tracker , internal ] unless id . nil? @waiting = id end dump ( tracker . command ) return tracker if id . nil? @return_mutex . synchronize { @return_condition . wait ( @return_mutex ) } tracker . status = true unless tracker . exit . nil? tracker . exit . each do | item | tracker . status = false if item . first == :error || item . first == 'error' end end tracker end
Pass nil pattern_action if you are not interested in doing anything.
Pass nil pattern_action if you are not interested in doing anything .
# There will be no responses.
pattern_action
command
user_id