Class: Fam::Connection

# Fam::Connection (Class)

In: | fam.c
Parent: | Data

## Methods

cancel_monitor close debug_level= fd monitor_collection monitor_directory monitor_file new new next_event open open2 pending? resume_monitor suspend_monitor

## Public Class methods

new(...)

Create a new connection to the FAM daemon.

Raises an ArgumentError exception if the number of arguments is not 0 or 1, or a Fam::Error exception if a connection to FAM could not be established.

Examples:

      # connect and tell FAM the application is named 'foo'
      fam = Fam::Connection.new 'foo'

      # just connect
      fam = Fam::Connection.new

new(...)

Create a new connection to the FAM daemon.

Examples:

      # connect and tell FAM the application is named 'foo'
      fam = Fam::Connection.new 'foo'

      # just connect
      fam = Fam::Connection.new

open(...)

Create a new connection to the FAM daemon.

Aliases:

      Fam::Connection.open2

Examples:

      # connect and tell FAM the application is named 'foo'
      fam = Fam::Connection.open 'foo'

      # just connect
      fam = Fam::Connection.open

      # connect and close automatically
      Fam::Connection.open('foo') {|fam| ... }

open2(...)

Create a new connection to the FAM daemon.

Aliases:

      Fam::Connection.open2

Examples:

      # connect and tell FAM the application is named 'foo'
      fam = Fam::Connection.open 'foo'

      # just connect
      fam = Fam::Connection.open

      # connect and close automatically
      Fam::Connection.open('foo') {|fam| ... }

## Public Instance methods

cancel_monitor(p1)

Cancel a monitor request.

Raises a Fam::Error exception if the monitor request could not be cancelled.

Note: this method invalidates the specified monitor request.

Aliases:

      Fam::Connection#cancel

Examples:

      fam.cancel_monitor req
      fam.cancel req

close()

this causes a segfault, since ruby attempts to close the connection when it goes out of scope. We‘ll let ruby take care of it. :)

debug_level=(p1)

Set the debug level of a Fam::Connection object.

Raises a Fam::Error exception on failure.

Aliases:

      Fam::Connection#debug

Examples:

      fam.debug = Fam::Debug::VERBOSE

fd()

Get the file descriptor of a Fam::Connection object.

Note: This method allows you to wait for FAM events using select() instead of polling via Fam::Connection#pending and Fam::Connection#next_event; see the second example below for more information.

Aliases:

      Fam::Connection#get_descriptor
      Fam::Connection#descriptor
      Fam::Connection#get_fd

Examples:

      # simple use
      fd = fam.fd

      # wrap the FAM connection descriptor in an IO object for use in a
      # select() call
      io = IO.new fam.fd, 'r'
      select [io], , , 10

monitor_collection(p1, p2)

Monitor a collection.

Raises a Fam::Error exception if the collection could not be monitored.

Aliases:

      Fam::Collection#monitor_col
      Fam::Collection#col

Examples:

      req = fam.monitor_col 'download/images', 1, '*.jpg'

monitor_directory(p1)

Monitor a directory.

Returns a Fam::Request object, which is used to identify the monitor associated with events.

Raises a Fam::Error exception if the directory could not be monitored.

Aliases:

      Fam::Connection#monitor_dir
      Fam::Connection#directory
      Fam::Connection#dir

Examples:

      req = fam.monitor_directory '/tmp'

monitor_file(p1)

Monitor a file.

Returns a Fam::Request object, which is used to identify the monitor associated with events.

Raises a Fam::Error exception if the file could not be monitored.

Aliases:

      Fam::Connection#file

Examples:

      req = fam.monitor_file '/var/log/messages'

next_event()

Get the next event from the event queue, or block until an event is available.

Raises a Fam::Error exception if FAM couldn’t check for pending events, or if FAM-Ruby couldn’t get the next FAM event.

Aliases:

      Fam::Connection#next_ev
      Fam::Connection#ev

Examples:

      ev = fam.next_event

pending?()

Are there any events in the queue?

Raises a Fam::Error exception if FAM couldn’t check for pending events.

Aliases:

      Fam::Connection#pending

Examples:

      puts 'no events pending' unless fam.pending?

resume_monitor(p1)

Resume (start monitoring) a monitor request.

Raises a Fam::Error exception if the monitor request could not be resumed.

Aliases:

      Fam::Connection#resume

Examples:

      fam.resume_monitor req
      fam.resume req

suspend_monitor(p1)

Suspend (stop monitoring) a monitor request.

Raises a Fam::Error exception if the monitor request could not be suspended.

Aliases:

      Fam::Connection#suspend

Examples:

      fam.suspend_monitor req
      fam.suspend req

[Validate]