Class: PalavaMachine::SocketStore
- Inherits:
-
Object
- Object
- PalavaMachine::SocketStore
- Includes:
- Enumerable
- Defined in:
- lib/palava_machine/socket_store.rb
Instance Method Summary collapse
- #dup ⇒ Object
- #each(&block) ⇒ Object
- #get_connection(id) ⇒ Object (also: #[])
- #get_connection_id(ws) ⇒ Object
- #ids ⇒ Object
-
#initialize(connections = {}) ⇒ SocketStore
constructor
A new instance of SocketStore.
- #register_connection(ws) ⇒ Object
- #sockets ⇒ Object
- #unregister_connection(ws) ⇒ Object
Constructor Details
permalink #initialize(connections = {}) ⇒ SocketStore
Returns a new instance of SocketStore.
9 10 11 |
# File 'lib/palava_machine/socket_store.rb', line 9 def initialize(connections = {}) @connections = connections.dup end |
Instance Method Details
permalink #dup ⇒ Object
[View source]
42 43 44 |
# File 'lib/palava_machine/socket_store.rb', line 42 def dup SocketStore.new(@connections) # TODO verify (shallow) end |
permalink #each(&block) ⇒ Object
[View source]
30 31 32 |
# File 'lib/palava_machine/socket_store.rb', line 30 def each(&block) @connections.each(&block) end |
permalink #get_connection(id) ⇒ Object Also known as: []
[View source]
25 26 27 |
# File 'lib/palava_machine/socket_store.rb', line 25 def get_connection(id) @connections.key(id) end |
permalink #get_connection_id(ws) ⇒ Object
[View source]
21 22 23 |
# File 'lib/palava_machine/socket_store.rb', line 21 def get_connection_id(ws) @connections[ws] end |
permalink #ids ⇒ Object
[View source]
38 39 40 |
# File 'lib/palava_machine/socket_store.rb', line 38 def ids @connections.values end |
permalink #register_connection(ws) ⇒ Object
[View source]
13 14 15 |
# File 'lib/palava_machine/socket_store.rb', line 13 def register_connection(ws) @connections[ws] = SecureRandom.uuid end |
permalink #sockets ⇒ Object
[View source]
34 35 36 |
# File 'lib/palava_machine/socket_store.rb', line 34 def sockets @connections.keys end |
permalink #unregister_connection(ws) ⇒ Object
[View source]
17 18 19 |
# File 'lib/palava_machine/socket_store.rb', line 17 def unregister_connection(ws) @connections.delete(ws) end |