Class: Sumac::Handshake
- Includes:
- Emittable
- Defined in:
- lib/sumac/handshake.rb
Instance Method Summary collapse
-
#initialize(connection) ⇒ Handshake
constructor
A new instance of Handshake.
- #receive(message) ⇒ Object
- #send_compatibility_notification ⇒ Object
- #send_initialization_notification ⇒ Object
Constructor Details
#initialize(connection) ⇒ Handshake
Returns a new instance of Handshake.
5 6 7 8 |
# File 'lib/sumac/handshake.rb', line 5 def initialize(connection) raise "argument 'connection' must be a Connection" unless connection.is_a?(Connection) @connection = connection end |
Instance Method Details
#receive(message) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sumac/handshake.rb', line 29 def receive() case when Message::Exchange::CompatibilityNotification raise MessageError unless @connection.at?(:compatibility_handshake) #unless message.protocol_version == 1 # @connection.to(:kill) #end @connection.to(:initialization_handshake) when Message::Exchange::InitializationNotification raise MessageError unless @connection.at?(:initialization_handshake) @connection.to(:active) @connection.remote_entry.set(.entry) else raise MessageError end nil end |
#send_compatibility_notification ⇒ Object
10 11 12 13 14 15 |
# File 'lib/sumac/handshake.rb', line 10 def send_compatibility_notification = Message::Exchange::CompatibilityNotification.new(@connection) .protocol_version = 1 @connection.messenger.send() nil end |
#send_initialization_notification ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sumac/handshake.rb', line 17 def send_initialization_notification = Message::Exchange::InitializationNotification.new(@connection) begin .entry = @connection.local_entry rescue UnexposableObjectError @connection.to(:kill) else @connection.messenger.send() end nil end |