Class: ItunesController::LoginCommand

Inherits:
ServerCommand show all
Defined in:
lib/itunesController/controllserver.rb

Overview

The login command taks the format LOGIN:<username> and causes the server to prompt for a password. This command is used to start the user login process

Instance Attribute Summary

Attributes inherited from ServerCommand

#name, #requiredLoginState, #singleThreaded

Instance Method Summary collapse

Methods inherited from ServerCommand

#executeSingleThreaded, #processLine

Constructor Details

#initialize(state, itunes) ⇒ LoginCommand

The constructor

Parameters:



196
197
198
# File 'lib/itunesController/controllserver.rb', line 196

def initialize(state,itunes)
    super(ItunesController::CommandName::LOGIN,nil,false,state,itunes)
end

Instance Method Details

#processData(line, io) ⇒ Boolean, String

The line is processed to get the username, then the response “222 Password?” is sent to the the client to request the password.

Parameters:

  • data (String)

    The commands parameters if their are any

  • io

    A IO Stream that is used to talk to the connected client

Returns:

  • (Boolean, String)

    The returned status of the command. If the first part is false, then the server will disconnect the client. The second part is a string message send to the client



207
208
209
210
211
212
213
214
# File 'lib/itunesController/controllserver.rb', line 207

def processData(line,io)
    if (line =~ /^\:(.+)$/)
        @state.user=$1
        @state.state=ServerState::DOING_AUTH
        return true,"222 Password?\r\n"
    end
    return false, "502 ERROR no username\r\n"
end