mojodna-switchboard 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.executables = ["switchboard"]
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_dependency("mojodna-xmpp4r", ">=", "0.4.0.1")
19
+ s.add_dependency("mojodna-xmpp4r", ">=", "0.4.0.2")
20
20
  end
21
21
  EOF
22
22
 
@@ -43,12 +43,11 @@ module Switchboard
43
43
  exit
44
44
  end
45
45
 
46
- @deferreds.each do |name, deferred|
47
- puts "Killing #{name}" if debug?
48
- deferred.kill
49
- end
46
+ die
47
+ end
50
48
 
51
- shutdown!
49
+ at_exit do
50
+ die
52
51
  end
53
52
 
54
53
  @settings = settings
@@ -60,8 +59,12 @@ module Switchboard
60
59
 
61
60
  # Start running.
62
61
  def run!
62
+ @main_thread = Thread.current
63
+
63
64
  startup
64
65
 
66
+ @ready = true
67
+
65
68
  if @main
66
69
  instance_eval(&@main)
67
70
  elsif loop?
@@ -119,6 +122,10 @@ module Switchboard
119
122
  end
120
123
  end
121
124
 
125
+ def ready?
126
+ @ready
127
+ end
128
+
122
129
  hook(:exception, :iq, :message, :presence, :startup, :stream_connected, :shutdown)
123
130
 
124
131
  protected
@@ -135,6 +142,22 @@ module Switchboard
135
142
  settings["debug"]
136
143
  end
137
144
 
145
+ def die
146
+ @deferreds.each do |name, deferred|
147
+ puts "Killing #{name}" if debug?
148
+ deferred.kill
149
+ end
150
+
151
+ shutdown!
152
+
153
+ timeout(15) do
154
+ sleep 0.1 until shutdown_complete?
155
+ end
156
+
157
+ rescue Timeout::Error
158
+ puts "Shutdown timed out."
159
+ end
160
+
138
161
  def disconnect!
139
162
  stream.close
140
163
  end
@@ -244,7 +267,7 @@ module Switchboard
244
267
  end
245
268
 
246
269
  def shutdown(run_hooks = true)
247
- if Thread.current != Thread.main
270
+ if Thread.current != @main_thread
248
271
  $stderr.puts "Wrong thread! You should be using #shutdown! instead."
249
272
  shutdown!
250
273
  return
@@ -260,10 +283,16 @@ module Switchboard
260
283
 
261
284
  puts "Shutting down..." if debug?
262
285
  disconnect! if connected?
286
+
287
+ @shutdown_complete = true
263
288
  end
264
289
 
265
290
  def shutdown?
266
291
  @shutdown
267
292
  end
293
+
294
+ def shutdown_complete?
295
+ @shutdown_complete
296
+ end
268
297
  end
269
298
  end
@@ -1,3 +1,3 @@
1
1
  module Switchboard
2
- VERSION = [0, 0, 9]
2
+ VERSION = [0, 0, 10]
3
3
  end
data/switchboard.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # this file is automatically generated
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "switchboard"
4
- s.version = "0.0.9"
4
+ s.version = "0.0.10"
5
5
  s.summary = "XMPP toolkit."
6
6
  s.description = "A toolkit for assembling XMPP clients and interacting with XMPP servers."
7
7
  s.authors = ["Seth Fitzsimmons"]
@@ -11,5 +11,5 @@ Gem::Specification.new do |s|
11
11
  s.executables = ["switchboard"]
12
12
  s.require_paths = ["lib"]
13
13
 
14
- s.add_dependency("mojodna-xmpp4r", ">=", "0.4.0.1")
14
+ s.add_dependency("mojodna-xmpp4r", ">=", "0.4.0.2")
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mojodna-switchboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Fitzsimmons
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: "0"
23
23
  - - "="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.4.0.1
25
+ version: 0.4.0.2
26
26
  version:
27
27
  description: A toolkit for assembling XMPP clients and interacting with XMPP servers.
28
28
  email: