async-slack 0.1.1 → 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
  SHA256:
3
- metadata.gz: a64150cb0b14528d0e8b5086f0763b18d0384d32591caae16f07eae3ad5bba20
4
- data.tar.gz: 4197055f6f5fcd96abdfe2dd24110d009443d028dac0aba7b59459d6d521230e
3
+ metadata.gz: d3fca86c14e3ed76970f56c65c20e204875ad6ced23aa3f95830b76b6e4e978c
4
+ data.tar.gz: f4d59d3289a976bfb12e10c9f5453f6dd24de63c8b54cc2dbb4454692205473e
5
5
  SHA512:
6
- metadata.gz: 2d852cef4378305932aaa3069a4fc73b07208feb27068c096fb9c6866e811b582a3dfb87432a8a5934144f6b3233a76afb8b55957aed8ca34b3ffaa0133a73ee
7
- data.tar.gz: 1b97a8d12e4e665587f4ca299537cdd9e48558f151560108de5aaae635ef37573016e2e78bc5651b5600519806aacd752cc9bf475ea79905bda6948178dc9430
6
+ metadata.gz: 0b0d890ae747f3db3397a0b5eca3de4f6689fa2ef87e276af6d82f97dcb53ab9f8c07aa07b2f935a7a371ed8b36bbee6ea3a3b7ae9573fbfecc8c42ffedc97f8
7
+ data.tar.gz: 6459df53d55475e970a22f2ddb90d5fc6b191bca2bfd3c9bb0f522470814335b0ab7e4d41d736f0870dcdf31db5f716a0591d8db4e486668a49b1a90e9df627c
@@ -36,7 +36,29 @@ module Async
36
36
 
37
37
  endpoint = Async::HTTP::Endpoint.parse(url)
38
38
 
39
- Async::WebSocket::Client.connect(endpoint, **options, &block)
39
+ Async::WebSocket::Client.connect(endpoint, **options) do |connection|
40
+ self.start(connection, &block)
41
+ end
42
+ end
43
+
44
+ def start(connection, &block)
45
+ id = 1
46
+
47
+ pinger = Async do |task|
48
+ while true
49
+ task.sleep 2
50
+
51
+ Async.logger.debug(self) {"Sending ping #{id}..."}
52
+ connection.write({type: "ping", id: "pinger-#{id}"})
53
+ connection.flush
54
+
55
+ id += 1
56
+ end
57
+ end
58
+
59
+ yield connection
60
+ ensure
61
+ pinger.stop
40
62
  end
41
63
  end
42
64
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Async
3
3
  module Slack
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams