Sha256: 0090d5d7d8f830fe10d9cea02164c3bbbea93c4e92961fef19d018adba172625

Contents?: true

Size: 972 Bytes

Versions: 33

Compression:

Stored size: 972 Bytes

Contents

class Openall_time_applet::Unix_socket
  def initialize(args)
    @args = args
    
    #Remove the sock-file if it already exists.
    File.unlink(Openall_time_applet::CONFIG[:sock_path]) if File.exists?(Openall_time_applet::CONFIG[:sock_path])
    
    #Start Unix-socket.
    require "socket"
    @usock = UNIXServer.new(Openall_time_applet::CONFIG[:sock_path])
    
    #Remove the sock-file after this process is done.
    Kernel.at_exit do
      File.unlink(Openall_time_applet::CONFIG[:sock_path]) if File.exists?(Openall_time_applet::CONFIG[:sock_path])
    end
    
    #Start thread that listens for connections through the Unix-socket.
    Knj::Thread.new do
      while client = @usock.accept
        client.each_line do |line|
          line = line.strip
          
          if line.strip == "open_main_window"
            @args[:oata].show_main
          else
            print "Unknown line: #{line}\n"
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
openall_time_applet-0.0.24 classes/unix_socket.rb
openall_time_applet-0.0.23 classes/unix_socket.rb
openall_time_applet-0.0.22 classes/unix_socket.rb
openall_time_applet-0.0.21 classes/unix_socket.rb
openall_time_applet-0.0.20 classes/unix_socket.rb
openall_time_applet-0.0.19 classes/unix_socket.rb
openall_time_applet-0.0.18 classes/unix_socket.rb
openall_time_applet-0.0.17 classes/unix_socket.rb
openall_time_applet-0.0.16 classes/unix_socket.rb
openall_time_applet-0.0.15 classes/unix_socket.rb
openall_time_applet-0.0.14 classes/unix_socket.rb
openall_time_applet-0.0.13 classes/unix_socket.rb
openall_time_applet-0.0.12 classes/unix_socket.rb