Class: InnerClientUpdater

Inherits:
Updater
  • Object
show all
Defined in:
lib/ff/ruby/server/sdk/api/inner_client_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(poll_processor, client_callback, logger = nil) ⇒ InnerClientUpdater

Returns a new instance of InnerClientUpdater.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ff/ruby/server/sdk/api/inner_client_updater.rb', line 7

def initialize(

  poll_processor,
  client_callback,
  logger = nil
)

  unless poll_processor.kind_of?(PollingProcessor)

    raise "The 'poll_processor' parameter must be of '" + PollingProcessor.to_s + "' data type"
  end

  unless client_callback.kind_of?(ClientCallback)

    raise "The 'client_callback' parameter must be of '" + ClientCallback.to_s + "' data type"
  end

  if logger != nil

    @logger = logger
  else

    @logger = Logger.new(STDOUT)
  end

  @poll_processor = poll_processor
  @client_callback = client_callback
end

Instance Method Details

#on_connectedObject



36
37
38
39
# File 'lib/ff/ruby/server/sdk/api/inner_client_updater.rb', line 36

def on_connected

  @poll_processor.stop
end

#on_disconnectedObject



41
42
43
44
45
46
47
# File 'lib/ff/ruby/server/sdk/api/inner_client_updater.rb', line 41

def on_disconnected

  unless @client_callback.is_closing

    @poll_processor.start
  end
end

#on_errorObject



54
55
56
57
# File 'lib/ff/ruby/server/sdk/api/inner_client_updater.rb', line 54

def on_error

  @logger.error "InnerClientUpdater error occurred"
end

#on_readyObject



49
50
51
52
# File 'lib/ff/ruby/server/sdk/api/inner_client_updater.rb', line 49

def on_ready

  @client_callback.on_update_processor_ready()
end

#update(message) ⇒ Object



59
60
61
62
# File 'lib/ff/ruby/server/sdk/api/inner_client_updater.rb', line 59

def update(message)

  @client_callback.update(message, false)
end