Class: ModSpox::Handlers::Ping

Inherits:
Handler
  • Object
show all
Defined in:
lib/mod_spox/handlers/Ping.rb

Instance Method Summary collapse

Methods inherited from Handler

#preprocess

Constructor Details

#initialize(handlers) ⇒ Ping

Returns a new instance of Ping.



5
6
7
# File 'lib/mod_spox/handlers/Ping.rb', line 5

def initialize(handlers)
    handlers[:PING] = self
end

Instance Method Details

#process(string) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mod_spox/handlers/Ping.rb', line 8

def process(string)
    orig = string.dup
    string = string.dup
    begin
        string.slice!(0) if string[0] == ':'
        server = string[0..string.index(' ')-1]
        message = string[string.index(':')+1..string.size]
        server = message.dup if server == 'PING'
        return Messages::Incoming::Ping.new(orig, server, message)
    rescue Object => boom
        Logger.error("Failed to parse PING message: #{string}")
        raise boom
    end
end