Class: Ferrum::SessionClient
- Inherits:
-
Object
- Object
- Ferrum::SessionClient
show all
- Defined in:
- lib/ferrum/client.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client, session_id) ⇒ SessionClient
Returns a new instance of SessionClient.
15
16
17
18
|
# File 'lib/ferrum/client.rb', line 15
def initialize(client, session_id)
@client = client
@session_id = session_id
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
37
38
39
|
# File 'lib/ferrum/client.rb', line 37
def method_missing(name, ...)
@client.send(name, ...)
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
9
10
11
|
# File 'lib/ferrum/client.rb', line 9
def client
@client
end
|
#session_id ⇒ Object
Returns the value of attribute session_id.
9
10
11
|
# File 'lib/ferrum/client.rb', line 9
def session_id
@session_id
end
|
Class Method Details
.event_name(event, session_id) ⇒ Object
11
12
13
|
# File 'lib/ferrum/client.rb', line 11
def self.event_name(event, session_id)
[event, session_id].compact.join("_")
end
|
Instance Method Details
#close ⇒ Object
41
42
43
|
# File 'lib/ferrum/client.rb', line 41
def close
@client.subscriber.clear(session_id: session_id)
end
|
#command(method, async: false, **params) ⇒ Object
20
21
22
23
|
# File 'lib/ferrum/client.rb', line 20
def command(method, async: false, **params)
message = build_message(method, params)
@client.send_message(message, async: async)
end
|
#on(event, &block) ⇒ Object
25
26
27
|
# File 'lib/ferrum/client.rb', line 25
def on(event, &block)
@client.on(event_name(event), &block)
end
|
#respond_to_missing?(name, include_private) ⇒ Boolean
33
34
35
|
# File 'lib/ferrum/client.rb', line 33
def respond_to_missing?(name, include_private)
@client.respond_to?(name, include_private)
end
|
#subscribed?(event) ⇒ Boolean
29
30
31
|
# File 'lib/ferrum/client.rb', line 29
def subscribed?(event)
@client.subscribed?(event_name(event))
end
|