Module: RuneRb::Network::RS317::CommandMessage

Includes:
System::Log
Defined in:
app/network/protocol/rs317/incoming/command.rb

Overview

Since:

  • 0.9.3

Instance Method Summary collapse

Methods included from System::Log

#class_name, #err, #err!, #log, #log!, #symbolize_file

Instance Method Details

#parse(context) ⇒ Object

Parses the CommandMessage

Parameters:

Since:

  • 0.9.3


6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/network/protocol/rs317/incoming/command.rb', line 6

def parse(context)
  command_string = read_string.split(' ')
  label = command_string.shift

  log "Parsing command: #{label}" if RuneRb::GLOBAL[:DEBUG]
  command = context.fetch_command(label&.capitalize&.to_sym)
  if command
    command.new({ context: context, world: context.world, message: self, command: command_string })
  else
    context.session.write_message(:SystemTextMessage, message: "Could not parse Command: #{label.capitalize}")
  end
end