Class: IRC::Server::Dispatcher::ConnectionDispatcher::Connections
- Defined in:
- lib/failirc/server/dispatcher/connectiondispatcher.rb
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #clients ⇒ Object
- #delete(socket) ⇒ Object
- #empty? ⇒ Boolean
- #exists?(socket) ⇒ Boolean
-
#initialize(server) ⇒ Connections
constructor
A new instance of Connections.
- #links ⇒ Object
- #listening ⇒ Object
- #sockets ⇒ Object
- #things ⇒ Object
Constructor Details
#initialize(server) ⇒ Connections
Returns a new instance of Connections.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 37 def initialize (server) @server = server @data = ThreadSafeHash.new @data[:listening] = { :sockets => [], :data => {}, } @data[:sockets] = [] @data[:things] = {} @data[:clients] = CaseInsensitiveHash.new @data[:links] = CaseInsensitiveHash.new end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
35 36 37 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 35 def server @server end |
Instance Method Details
#clients ⇒ Object
65 66 67 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 65 def clients @data[:clients] end |
#delete(socket) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 81 def delete (socket) if !exists?(socket) return end thing = @data[:things][socket] if thing.is_a?(Client) @data[:clients].delete(thing.nick) @data[:clients].delete(socket) elsif thing.is_a?(Link) @data[:links].delete(thing.host) @data[:links].delete(socket) end @data[:sockets].delete(socket) @data[:things].delete(socket) end |
#empty? ⇒ Boolean
73 74 75 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 73 def empty? sockets.empty? end |
#exists?(socket) ⇒ Boolean
77 78 79 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 77 def exists? (socket) things[socket] ? true : false end |
#links ⇒ Object
69 70 71 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 69 def links @data[:links] end |
#listening ⇒ Object
53 54 55 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 53 def listening @data[:listening] end |
#sockets ⇒ Object
57 58 59 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 57 def sockets @data[:sockets] end |
#things ⇒ Object
61 62 63 |
# File 'lib/failirc/server/dispatcher/connectiondispatcher.rb', line 61 def things @data[:things] end |