Class: Droonga::Client::Connection::DroongaProtocol::Coolio::Receiver

Inherits:
Coolio::TCPServer
  • Object
show all
Defined in:
lib/droonga/client/connection/droonga-protocol/coolio.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Receiver

Returns a new instance of Receiver.



62
63
64
65
66
67
68
69
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 62

def initialize(*args)
  super(*args) do |engine|
    @engines << engine
    handle_engine(engine)
  end
  @requests = {}
  @engines = []
end

Instance Method Details

#closeObject



71
72
73
74
75
76
77
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 71

def close
  super
  @engines.each do |engine|
    engine.close
  end
  @engines.clear
end

#droonga_nameObject



87
88
89
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 87

def droonga_name
  "#{host}:#{port}/droonga"
end

#hostObject



79
80
81
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 79

def host
  @listen_socket.addr[3]
end

#portObject



83
84
85
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 83

def port
  @listen_socket.addr[1]
end

#received?(id) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
105
106
107
108
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 102

def received?(id)
  if @requests.key?(id)
    @requests[id][:received]
  else
    true
  end
end

#register(id, &callback) ⇒ Object



91
92
93
94
95
96
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 91

def register(id, &callback)
  @requests[id] = {
    :received => false,
    :callback => callback,
  }
end

#unregister(id) ⇒ Object



98
99
100
# File 'lib/droonga/client/connection/droonga-protocol/coolio.rb', line 98

def unregister(id)
  @requests.delete(id)
end