Module: BMF
- Defined in:
- lib/bmf.rb,
lib/bmf/lib/xmlrpc_client.rb
Defined Under Namespace
Modules: Message
Classes: AddressStore, Alert, BMF, Folder, MessageStore, Settings, ThreadStatus, XmlrpcClient, XmlrpcClientError
Class Method Summary
collapse
Class Method Details
.boot ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/bmf.rb', line 26
def self.boot
puts "Doing initial sync before starting..."
sync
Alert.instance.pop_new_messages
Thread.new do
while(1) do
sync_interval = Settings.instance.sync_interval.to_i
sync_interval = 60 if sync_interval == 0
sleep(sync_interval)
begin
sync
rescue Exception => ex
msg = "Background sync faild with #{ex.message}"
Alert.instance << msg
puts msg
puts ex.backtrace.join("\n")
end
end
end
BMF.run! do |server|
settings = Settings.instance
if (settings.https_server_key_file && settings.https_server_key_file != "") &&
(settings.https_server_certificate_file && settings.https_server_certificate_file != "")
puts "Requiring https..."
ssl_options = {
:cert_chain_file => settings.https_server_certificate_file,
:private_key_file => settings.https_server_key_file,
:verify_peer => false
}
server.ssl = true
server.ssl_options = ssl_options
else
puts "NOT requiring https. Traffic is unencrypted..."
end
end
end
|
.puts_and_alert(msg) ⇒ Object
8
9
10
11
|
# File 'lib/bmf.rb', line 8
def self.puts_and_alert msg
puts msg
Alert.instance << msg
end
|
.sync ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/bmf.rb', line 13
def self.sync
new_messages = MessageStore.instance.update
Alert.instance.add_new_messages(new_messages)
AddressStore.instance.update
rescue Errno::ECONNREFUSED => ex
puts_and_alert "Background sync. Couldn't connect to PyBitmessage server. Is it running with the API enabled? "
rescue JSON::ParserError => ex
puts_and_alert "Couldn't background sync. It seems like PyBitmessage is running but refused access. Do you have the correct info in config/settings.yml? "
rescue Exception => ex
puts_and_alert "Background Sync failed with #{ex.message}"
end
|