lib/yolodice_client.rb
##
# Closes connection to the host.
Closes connection to the host.
Closes connection to the host .
def close
    log.debug "Closing connection"
    @connection.close
    message = { 'client_error' => 'Connection closed' }
    while(callback = @thread_semaphore.synchronize{ @current_requests.shift }) do
      callback = callback[1]
      if callback.is_a? Integer
        @receive_queues[callback] << message
      elsif callback.is_a? Proc
        Thread.new do
          callback.call message
        end
      end
    end
    @pinging_thread.kill
    @listening_thread.kill
    true
  end
def close log . debug "Closing connection" @connection . close message = { 'client_error' => 'Connection closed' } while ( callback = @thread_semaphore . synchronize { @current_requests . shift } ) do callback = callback [ 1 ] if callback . is_a? Integer @receive_queues [ callback ] << message elsif callback . is_a? Proc Thread . new do callback . call message end end end @pinging_thread . kill @listening_thread . kill true end
Closes connection to the host.
Closes connection to the host .
# Stop threads # Send error to all pending requests # it's a thread # A thread pool would be better. # Thread.stop