Method: Faye::Server#advize

Defined in:
lib/faye/protocol/server.rb

#advize(response, connection_type) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/faye/protocol/server.rb', line 134

def advize(response, connection_type)
  return unless [Channel::HANDSHAKE, Channel::CONNECT].include?(response['channel'])

  if connection_type == 'eventsource'
    interval = (@engine.timeout * 1000).floor
    timeout  = 0
  else
    interval = (@engine.interval * 1000).floor
    timeout  = (@engine.timeout * 1000).floor
  end

  advice = response['advice'] ||= {}
  if response['error']
    advice['reconnect'] ||= 'handshake'
  else
    advice['reconnect'] ||= 'retry'
    advice['interval']  ||= interval
    advice['timeout']   ||= timeout
  end
end