class ADAM6050::Handler::Login

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.

Constants

MESSAGE_PREAMBLE

@return [String] see Handler::MESSAGE_PREAMBLE.

Public Class Methods

new(password = nil) click to toggle source

@param password [String] the plain text password to use when validating

login requests. If no password is given every request will be granted.
# File lib/adam6050/handler/login.rb, line 18
def initialize(password = nil)
  @password = Password.new password
  freeze
end

Public Instance Methods

handle(msg, state, session, sender) click to toggle source

@param msg [String] the incomming message. @param state [Integer] the current state. @param session [Session] the current session. @param sender [Socket::UDPSource] the UDP client.

@return [Integer] the next state (always unchanged). @return [String] a reply. The reply is either '>01' or '?' depending on

if the login attempt was successful or not.
# 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?() click to toggle source

@return [false] the login handler does not require the sender to be

validated.
# File lib/adam6050/handler/login.rb, line 41
def validate?
  false
end