Class: MessageFactory::Handlers::Pong

Inherits:
Handler
  • Object
show all
Defined in:
lib/messagefactory/handlers/PONG.rb

Instance Method Summary collapse

Instance Method Details

#process(string) ⇒ Object

string

string to process

Create a new Ping message OpenStruct will contain: #type #direction #raw #received #server #message :nodoc: :swiftco.wa.us.dal.net PONG swiftco.wa.us.dal.net :FOO



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/messagefactory/handlers/PONG.rb', line 15

def process(string)
    string = string.dup
    m = mk_struct(string)
    begin
        m.type = :pong
        string.slice!(0)
        m.server = string.slice!(0, string.index(' '))
        string.slice!(0)
        raise 'error' unless string.slice!(0, string.index(' ')).to_sym == :PONG
        if(string.index(':'))
            string.slice!(0, string.index(':')+1)
            m.message = string
        else
            m.message = ''
        end
    rescue
        raise "Failed to parse Pong message: #{m.raw}"
    end
    m
end

#types_processObject



7
8
9
# File 'lib/messagefactory/handlers/PONG.rb', line 7

def types_process
    :PONG
end