Class: Simultaneous::SyncClient
- Inherits:
-
Object
- Object
- Simultaneous::SyncClient
- Defined in:
- lib/simultaneous/sync_client.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
Instance Method Summary collapse
- #close ⇒ Object
- #connect ⇒ Object
-
#initialize(domain = Simultaneous.domain, connection_string = Simultaneous.connection) ⇒ SyncClient
constructor
A new instance of SyncClient.
- #on_event(event) ⇒ Object
- #run(command) ⇒ Object
- #send(command) ⇒ Object
Constructor Details
#initialize(domain = Simultaneous.domain, connection_string = Simultaneous.connection) ⇒ SyncClient
Returns a new instance of SyncClient.
9 10 11 12 |
# File 'lib/simultaneous/sync_client.rb', line 9 def initialize(domain = Simultaneous.domain, connection_string=Simultaneous.connection) @domain = domain @connection = Simultaneous::Connection.new(connection_string) end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
7 8 9 |
# File 'lib/simultaneous/sync_client.rb', line 7 def domain @domain end |
Instance Method Details
#close ⇒ Object
31 32 |
# File 'lib/simultaneous/sync_client.rb', line 31 def close end |
#connect ⇒ Object
25 26 27 28 29 |
# File 'lib/simultaneous/sync_client.rb', line 25 def connect @connection.sync_socket do |socket| yield(socket) end end |
#on_event(event) ⇒ Object
34 35 |
# File 'lib/simultaneous/sync_client.rb', line 34 def on_event(event) end |
#run(command) ⇒ Object
14 15 16 17 |
# File 'lib/simultaneous/sync_client.rb', line 14 def run(command) command.domain = self.domain send(command.dump) end |
#send(command) ⇒ Object
19 20 21 22 23 |
# File 'lib/simultaneous/sync_client.rb', line 19 def send(command) connect do |connection| connection.send(command, 0) end end |