Class: Wamp::Client::Manager::Establish
- Defined in:
- lib/wamp/client/manager/establish.rb
Constant Summary collapse
- WAMP_FEATURES =
{ caller: { features: { caller_identification: true, call_timeout: true, call_canceling: true, progressive_call_results: true } }, callee: { features: { caller_identification: true, ##call_trustlevels: true, pattern_based_registration: true, shared_registration: true, ##call_timeout: true, call_canceling: true, progressive_call_results: true, registration_revocation: true } }, publisher: { features: { publisher_identification: true, subscriber_blackwhite_listing: true, publisher_exclusion: true } }, subscriber: { features: { publisher_identification: true, ##publication_trustlevels: true, pattern_based_subscription: true, subscription_revocation: true ##event_history: true, } } }
Instance Attribute Summary collapse
-
#goodbye_sent ⇒ Object
Returns the value of attribute goodbye_sent.
-
#id ⇒ Object
Returns the value of attribute id.
-
#realm ⇒ Object
Returns the value of attribute realm.
Attributes inherited from Base
#send_message_callback, #session
Instance Method Summary collapse
-
#abort(message) ⇒ Object
Handles an abort message.
-
#challenge(message) ⇒ Object
Handles a challenge message.
-
#goodbye(message) ⇒ Object
Handles the goodbye message.
-
#initialize(session, send_message) ⇒ Establish
constructor
Constructor.
-
#is_open? ⇒ Boolean
Returns true if the session is open.
-
#join(realm) ⇒ Object
Will attempt to join a router.
-
#leave(reason, message) ⇒ Object
Leave the session.
-
#welcome(message) ⇒ Object
Handles the welcome message.
Constructor Details
#initialize(session, send_message) ⇒ Establish
Constructor
51 52 53 54 55 56 57 |
# File 'lib/wamp/client/manager/establish.rb', line 51 def initialize(session, ) super session, self.id = nil self.realm = nil self.goodbye_sent = false end |
Instance Attribute Details
#goodbye_sent ⇒ Object
Returns the value of attribute goodbye_sent.
8 9 10 |
# File 'lib/wamp/client/manager/establish.rb', line 8 def goodbye_sent @goodbye_sent end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/wamp/client/manager/establish.rb', line 8 def id @id end |
#realm ⇒ Object
Returns the value of attribute realm.
8 9 10 |
# File 'lib/wamp/client/manager/establish.rb', line 8 def realm @realm end |
Instance Method Details
#abort(message) ⇒ Object
Handles an abort message
156 157 158 159 160 161 162 |
# File 'lib/wamp/client/manager/establish.rb', line 156 def abort() # Log leaving the session logger.info("#{self.session.class.name} left session '#{.reason}'") # Trigger the leave event trigger :leave, .reason, .details end |
#challenge(message) ⇒ Object
Handles a challenge message
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/wamp/client/manager/establish.rb', line 136 def challenge() # Log challenge received logger.debug("#{self.session.class.name} auth challenge '#{.authmethod}', extra: #{.extra}") # Call the callback if set signature, extra = trigger :challenge, .authmethod, .extra # Set with initial values signature ||= '' extra ||= {} # Create the message authenticate = Message::Authenticate.new(signature, extra) # Send it (authenticate) end |
#goodbye(message) ⇒ Object
Handles the goodbye message
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/wamp/client/manager/establish.rb', line 105 def goodbye() # If we didn't send the goodbye, respond unless self.goodbye_sent goodbye = Message::Goodbye.new({}, 'wamp.error.goodbye_and_out') (goodbye) end # Close out session self.id = nil self.realm = nil self.goodbye_sent = false # Trigger leave event trigger :leave, .reason, .details end |
#is_open? ⇒ Boolean
Returns true if the session is open
61 62 63 |
# File 'lib/wamp/client/manager/establish.rb', line 61 def is_open? self.id != nil end |
#join(realm) ⇒ Object
Will attempt to join a router
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/wamp/client/manager/establish.rb', line 67 def join(realm) # Set the realm self.realm = realm # Create the details details = {} details[:roles] = WAMP_FEATURES details[:agent] = "Ruby-Wamp::Client-#{VERSION}" details[:authid] = self.session.[:authid] if self.session.[:authid] details[:authmethods] = self.session.[:authmethods] if self.session.[:authmethods] # Create the message hello = Message::Hello.new(realm, details) # Send it (hello) end |
#leave(reason, message) ⇒ Object
Leave the session
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/wamp/client/manager/establish.rb', line 87 def leave(reason, ) # Create the details details = {} details[:message] = # Create the goobdbye message goodbye = Message::Goodbye.new(details, reason) # Send it (goodbye) # Send it self.goodbye_sent = true end |
#welcome(message) ⇒ Object
Handles the welcome message
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/wamp/client/manager/establish.rb', line 123 def welcome() # Get the session ID self.id = .session # Log the message logger.info("#{self.session.class.name} joined session with realm '#{.details[:realm]}'") # Trigger join event trigger :join, .details end |