InputHandler.rb
RubyMud/InputHandler.rb · 868 B
From the archive rbmud-0.1rc2.tar.gz
Download the archive « Back to the archive contents
module RubyMud
class InputHandler
# used to handle input recieved on a client connection
def initialize(clientconnection)
@clientconnection = clientconnection
@theline = ""
end
# function gets called by ClientConnection whenever
# the user inputs a line
def recieve(line)
end
# function gets called by ClientConnection whenever
# the user inputs a char (deprecated at the moment)
def recieveChar(char)
if (("%c"%char) == "\t")
@clientconnection.send("\r\nTab pressed\r\n")
return
end
@theline += "%c" % char
if (("%c"%char) != "\n")
return
end
recieve(@theline)
@theline = ""
end
# Initialise an input handler with the clientConnection
# it should act on
def initialize(clientConnection)
@clientconnection = clientConnection
end
end
end