Class: ModSpox::Handlers::Pong

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

Instance Method Summary collapse

Methods inherited from Handler

#preprocess

Constructor Details

#initialize(handlers) ⇒ Pong

Returns a new instance of Pong.



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

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

Instance Method Details

#process(string) ⇒ Object



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

def process(string)
    orig = string.dup
    string = string.dup
    begin
        a = string.slice!(string.rindex(':')+1, string.size)
        string.slice!(-2..string.size)
        return Messages::Incoming::Pong.new(orig, string.slice(string.rindex(' ')+1..string.size), a)
    rescue Object => boom
        Logger.error("Failed to parse PONG message: #{orig}")
        raise boom
    end
end