mosq 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b296db03c458067273327316bdb11e9e363d671e
4
- data.tar.gz: 78c2ba4c4782f25a010398be2823161163b49411
3
+ metadata.gz: 6cbee712fb0536d070cb58d1d892d066992120a1
4
+ data.tar.gz: 5adaa9828b31824d8a08be875a2120ffb3892c17
5
5
  SHA512:
6
- metadata.gz: 07a7d0ab55446f767c6a81eba9eae3a1ea08524c55d2fc6f29a32a26e33e192a3bb01cd9e49ca4a9a0bef36b72d96f76c8f78466f1808d9acf7fb68504180a27
7
- data.tar.gz: 41e4acb30e8ae4c775864a1f6df4545f4ebde02850a5c02b3bdd0d100fed4dff417f3232ddd29a1140d2001f75484b26f1ab44f595cc342743860388bd5fbe02
6
+ metadata.gz: f1d2359634518bc1794b513bfbac245a951998b915c3360e724932d1ccf3902fdfa9c53727a02697f1cd1a06776a948a5030b66e8345861fc57a8775c208ca65
7
+ data.tar.gz: aea1439f96aead78b618debbdffd734f88cc646117957f5dd530d99e29ef02481b7be8185d50ab7cabdb05194469c8533e6072abb4b8a46bd2906e2f049a1ae7
@@ -14,7 +14,8 @@ module Mosq
14
14
  def initialize(*args)
15
15
  @options = Util.connection_info(*args)
16
16
 
17
- @options[:heartbeat] ||= 30 # seconds
17
+ @options[:max_in_flight] ||= 20 # messages
18
+ @options[:heartbeat] ||= 30 # seconds
18
19
  @protocol_timeout = DEFAULT_PROTOCOL_TIMEOUT
19
20
 
20
21
  Util.null_check "creating the client",
@@ -36,12 +37,13 @@ module Mosq
36
37
  end
37
38
  end
38
39
 
39
- def username; @options.fetch(:username); end
40
- def password; @options.fetch(:password); end
41
- def host; @options.fetch(:host); end
42
- def port; @options.fetch(:port); end
43
- def ssl?; @options.fetch(:ssl); end
44
- def heartbeat; @options.fetch(:heartbeat); end
40
+ def username; @options.fetch(:username); end
41
+ def password; @options.fetch(:password); end
42
+ def host; @options.fetch(:host); end
43
+ def port; @options.fetch(:port); end
44
+ def ssl?; @options.fetch(:ssl); end
45
+ def heartbeat; @options.fetch(:heartbeat); end
46
+ def max_in_flight; @options.fetch(:max_in_flight); end
45
47
 
46
48
  # The maximum time interval the user application should wait between
47
49
  # yielding control back to the client object by calling methods like
@@ -59,6 +61,9 @@ module Mosq
59
61
  # Initiate the connection with the server.
60
62
  # It is necessary to call this before any other communication.
61
63
  def start
64
+ Util.error_check "configuring the maximum number of inflight messages",
65
+ FFI.mosquitto_max_inflight_messages_set(ptr, @options[:max_in_flight])
66
+
62
67
  Util.error_check "configuring the username and password",
63
68
  FFI.mosquitto_username_pw_set(ptr, @options[:usernam], @options[:password])
64
69
 
@@ -5,15 +5,23 @@ module Mosq
5
5
  # @api private
6
6
  class Bucket
7
7
  def initialize(ptr)
8
- FFI.mosquitto_connect_callback_set ptr, method(:on_connect)
9
- # FFI.mosquitto_disconnect_callback_set ptr, method(:on_disconnect)
10
- FFI.mosquitto_publish_callback_set ptr, method(:on_publish)
11
- FFI.mosquitto_message_callback_set ptr, method(:on_message)
12
- FFI.mosquitto_subscribe_callback_set ptr, method(:on_subscribe)
13
- FFI.mosquitto_unsubscribe_callback_set ptr, method(:on_unsubscribe)
14
- # FFI.mosquitto_log_callback_set ptr, method(:on_log)
8
+ @events = []
9
+ @callbacks = {}
15
10
 
16
- @events = []
11
+ FFI.mosquitto_connect_callback_set ptr, new_callback(:on_connect)
12
+ # FFI.mosquitto_disconnect_callback_set ptr, new_callback(:on_disconnect)
13
+ FFI.mosquitto_publish_callback_set ptr, new_callback(:on_publish)
14
+ FFI.mosquitto_message_callback_set ptr, new_callback(:on_message)
15
+ FFI.mosquitto_subscribe_callback_set ptr, new_callback(:on_subscribe)
16
+ FFI.mosquitto_unsubscribe_callback_set ptr, new_callback(:on_unsubscribe)
17
+ # FFI.mosquitto_log_callback_set ptr, new_callback(:on_log)
18
+ end
19
+
20
+ def new_callback(symbol)
21
+ # This ensures that callback Procs are retained in the Bucket,
22
+ # and are not garbage-collected for the entire life of the Client.
23
+ # If the callback Procs are garbage-collected then invoked, SIGSEGV!
24
+ @callbacks[symbol] = method(symbol).to_proc
17
25
  end
18
26
 
19
27
  attr_reader :events
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mosq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe McIlvain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-13 00:00:00.000000000 Z
11
+ date: 2015-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi