Class: ADAM6050::Handler::Login

Inherits:
Object
  • Object
show all
Includes:
ADAM6050::Handler
Defined in:
lib/adam6050/handler/login.rb

Overview

Allows senders to login.

I have so far not been able to find any documentation around this feature. It is therefore almost certain that the response in case of an incorrect password is wrong.

Constant Summary collapse

MESSAGE_PREAMBLE =
'$01PW'

Instance Method Summary collapse

Methods included from ADAM6050::Handler

#handles?

Constructor Details

#initialize(password = nil) ⇒ Login



18
19
20
21
# File 'lib/adam6050/handler/login.rb', line 18

def initialize(password = nil)
  @password = Password.new password
  freeze
end

Instance Method Details

#handle(msg, state, session, sender) ⇒ Integer, String



31
32
33
34
35
36
37
# File 'lib/adam6050/handler/login.rb', line 31

def handle(msg, state, session, sender)
  return state, '?' unless @password == msg[6..-1].chomp!

  session.register sender

  [state, '>01']
end

#validate?false



41
42
43
# File 'lib/adam6050/handler/login.rb', line 41

def validate?
  false
end