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.
17
18
19
20
|
# File 'lib/ferrum/client.rb', line 17
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, *args, **opts, &block) ⇒ Object
43
44
45
|
# File 'lib/ferrum/client.rb', line 43
def method_missing(name, *args, **opts, &block)
@client.send(name, *args, **opts, &block)
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
11
12
13
|
# File 'lib/ferrum/client.rb', line 11
def client
@client
end
|
#session_id ⇒ Object
Returns the value of attribute session_id.
11
12
13
|
# File 'lib/ferrum/client.rb', line 11
def session_id
@session_id
end
|
Class Method Details
.event_name(event, session_id) ⇒ Object
13
14
15
|
# File 'lib/ferrum/client.rb', line 13
def self.event_name(event, session_id)
[event, session_id].compact.join("_")
end
|
Instance Method Details
#close ⇒ Object
47
48
49
|
# File 'lib/ferrum/client.rb', line 47
def close
@client.subscriber.clear(session_id: session_id)
end
|
#command(method, async: false, **params) ⇒ Object
22
23
24
25
|
# File 'lib/ferrum/client.rb', line 22
def command(method, async: false, **params)
message = build_message(method, params)
@client.send_message(message, async: async)
end
|
#off(event, id) ⇒ Object
31
32
33
|
# File 'lib/ferrum/client.rb', line 31
def off(event, id)
@client.off(event_name(event), id)
end
|
#on(event, &block) ⇒ Object
27
28
29
|
# File 'lib/ferrum/client.rb', line 27
def on(event, &block)
@client.on(event_name(event), &block)
end
|
#respond_to_missing?(name, include_private) ⇒ Boolean
39
40
41
|
# File 'lib/ferrum/client.rb', line 39
def respond_to_missing?(name, include_private)
@client.respond_to?(name, include_private)
end
|
#subscribed?(event) ⇒ Boolean
35
36
37
|
# File 'lib/ferrum/client.rb', line 35
def subscribed?(event)
@client.subscribed?(event_name(event))
end
|