Parent

Included Modules

Listen::Adapter::TCP

Adapter to receive file system modifications over TCP

Constants

RECEIVE_WINDOW

Number of bytes to receive at a time

Attributes

buffer[R]
socket[R]

Public Class Methods

local_fs?() click to toggle source
# File lib/listen/adapter/tcp.rb, line 60
def self.local_fs?
  false
end
usable?() click to toggle source
# File lib/listen/adapter/tcp.rb, line 13
def self.usable?
  true
end

Public Instance Methods

finalize() click to toggle source

Cleans up buffer and socket

# File lib/listen/adapter/tcp.rb, line 25
def finalize
  @buffer = nil
  if @socket
    @socket.close
    @socket = nil
  end
end
handle_data(data) click to toggle source

Buffers incoming data and handles messages accordingly

# File lib/listen/adapter/tcp.rb, line 44
def handle_data(data)
  @buffer << data
  while (message = Listen::TCP::Message.from_buffer(@buffer))
    handle_message(message)
  end
end
handle_message(message) click to toggle source

Handles incoming message by notifying of path changes

# File lib/listen/adapter/tcp.rb, line 52
def handle_message(message)
  message.object.each do |change, paths|
    paths.each do |path|
      _notify_change(path, change: change.to_sym)
    end
  end
end
run() click to toggle source

Continuously receive and asynchronously handle data

# File lib/listen/adapter/tcp.rb, line 37
def run
  while (data = @socket.recv(RECEIVE_WINDOW))
    async.handle_data(data)
  end
end
start() click to toggle source

Initializes and starts a Celluloid::IO-powered TCP-recipient

# File lib/listen/adapter/tcp.rb, line 18
def start
  @socket = TCPSocket.new(listener.host, listener.port)
  @buffer = ''
  run
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.