Sha256: 6c16e1bc07964ce20fcd248c2021e4d11305af370e8dd6d188443c2fc216601d

Contents?: true

Size: 661 Bytes

Versions: 3

Compression:

Stored size: 661 Bytes

Contents

module Faye
  module Reconnect
    class ServerExtension

      def initialize(app)
        @server = app.instance_variable_get(:@server)
      end

      def incoming(message, callback)
        if message.key?('previousClientId')
          client_id = message['previousClientId']
          @server.engine.client_exists(client_id) do |exists|
            if exists
              @server.engine.ping(client_id)
              message['clientId'] = client_id
              message['error'] = 'Already connected'
            end
            callback.call(message)
          end
        else
          callback.call(message)
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faye-reconnect-1.0.0 lib/faye/reconnect/server_extension.rb
faye-reconnect-0.0.3 lib/faye/reconnect/server_extension.rb
faye-reconnect-0.0.2 lib/faye/reconnect/server_extension.rb