Module: Fargo::Supports::Persistence

Extended by:
ActiveSupport::Concern
Included in:
Client
Defined in:
lib/fargo/supports/persistence.rb

Instance Method Summary collapse

Instance Method Details

#connect_with(nick) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fargo/supports/persistence.rb', line 10

def connect_with nick
  @connection_timeouts[nick] = EventMachine::Timer.new(10) do
    @connection_timeouts.delete(nick)
    channel << [:connection_timeout, {:nick => nick}]
  end

  if config.passive
    hub.send_message 'RevConnectToMe', "#{self.config.nick} #{nick}"
  else
    hub.send_message 'ConnectToMe',
      "#{nick} #{config.address}:#{config.active_port}"
  end
end

#connected_with?(nick) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/fargo/supports/persistence.rb', line 28

def connected_with? nick
  @connection_cache.has_key? nick
end

#connection_for(nick) ⇒ Object



24
25
26
# File 'lib/fargo/supports/persistence.rb', line 24

def connection_for nick
  @connection_cache[nick]
end

#disconnect_from(nick) ⇒ Object



32
33
34
35
# File 'lib/fargo/supports/persistence.rb', line 32

def disconnect_from nick
  c = @connection_cache.delete nick
  c.try :close_connection_after_writing
end

#nicks_connected_withObject



37
38
39
# File 'lib/fargo/supports/persistence.rb', line 37

def nicks_connected_with
  @connection_cache.keys
end