Class: LS4::SyncServerService

Inherits:
SyncService show all
Defined in:
lib/ls4/service/sync.rb

Direct Known Subclasses

StandaloneSyncService

Instance Method Summary collapse

Methods inherited from SyncService

#get_hash

Methods inherited from Service

init

Methods included from EventBus::SingletonMixin

#ebus_bind!, #ebus_connect, extended

Methods included from EventBus::BusMixin

#ebus_all_slots, #ebus_disconnect!

Methods included from EventBus::DeclarerBase::Methods

#connect, #ebus_all_slots, #ebus_call_log, #ebus_call_slots, #ebus_signal_error, #ebus_signal_log, #ebus_signal_slots

Methods included from EventBus::DeclarerBase

#call_slot, #signal_slot

Constructor Details

#initializeSyncServerService

Returns a new instance of SyncServerService.



60
61
62
63
# File 'lib/ls4/service/sync.rb', line 60

def initialize
  @data_array = []
  super
end

Instance Method Details

#check_hash(hash) ⇒ Object



65
66
67
# File 'lib/ls4/service/sync.rb', line 65

def check_hash(hash)
  @hash == hash
end

#rpc_sync_config(hash_array) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ls4/service/sync.rb', line 76

def rpc_sync_config(hash_array)
  result = []

  hash_array.each_with_index {|hash,id|
    if h = @hash_array[id]
      if h != hash
        result[id] = @data_array[id]
      end
    end
  }

  result
end

#update(id, data, hash) ⇒ Object



69
70
71
72
73
74
# File 'lib/ls4/service/sync.rb', line 69

def update(id, data, hash)
  @data_array[id] = data
  @hash_array[id] = hash
  update_hash
  nil
end