websocket-driver 0.6.5 → 0.7.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: 45f6962eb4b7b927eddff1e14c1368464227ef7f
4
- data.tar.gz: 8e98a4638c104fce2ccc752f87eadd1269f8a643
3
+ metadata.gz: 0ddf5e80d9f5080fc8d494d3e93611cdd23eb759
4
+ data.tar.gz: 15ad3e7d961a9940971a76817ceb6ce0bba8a6f0
5
5
  SHA512:
6
- metadata.gz: fcc93ef62b0bd24fb9f1687874591ff7747c0a02896d395195ff699381b9c3d4d1888c4fbe079e017442f8e79a8c908c514fdf4550f872303fef6351c7484bb2
7
- data.tar.gz: 1f9215cc0926f4d7d6d083939dc2a8c83a6ca89e1eb30af2ae064ec16239936a12f69cd4a2dda12651358a2402a90fd59533b00b8d18e413d580269a418a2bc3
6
+ metadata.gz: 3655528c0e0533a75512fc1e69044b03506fdf9d751d0c41875b1efea98f0eae55024887e6445fa17a30fc8996b85d3ca808e89bb72631c1f7fc6ac99a39e227
7
+ data.tar.gz: 0d85ca3a28fcb776bcb292ad90886cd98e27ad84739bcab1478e37b36afe8c964475faf4fda0201fd35cbf3dc006106a89db4da808085585c7d292cac5821739
@@ -1,3 +1,7 @@
1
+ ### 0.7.0 / 2017-09-11
2
+
3
+ * Add `ping` and `pong` to the set of events users can listen to
4
+
1
5
  ### 0.6.5 / 2017-01-22
2
6
 
3
7
  * Provide a pure-Ruby fallback for the native unmasking code
data/LICENSE.md CHANGED
@@ -1,6 +1,4 @@
1
- # License
2
-
3
- (The MIT License)
1
+ # The MIT License
4
2
 
5
3
  Copyright (c) 2010-2017 James Coglan
6
4
 
data/README.md CHANGED
@@ -295,6 +295,17 @@ describing the error.
295
295
  Adds a callback block to execute when the socket becomes closed. The `event`
296
296
  object has `code` and `reason` attributes.
297
297
 
298
+ #### `driver.on :ping, -> (event) { }`
299
+
300
+ Adds a callback block to execute when a ping is received. You do not need to
301
+ handle this by sending a pong frame yourself; the driver handles this for you.
302
+
303
+ #### `driver.on :pong, -> (event) { }`
304
+
305
+ Adds a callback block to execute when a pong is received. If this was in
306
+ response to a ping you sent, you can also handle this event via the
307
+ `driver.ping(message) { ... }` callback.
308
+
298
309
  #### `driver.add_extension(extension)`
299
310
 
300
311
  Registers a protocol extension whose operation will be negotiated via the
@@ -50,6 +50,8 @@ module WebSocket
50
50
  ConnectEvent = Struct.new(nil)
51
51
  OpenEvent = Struct.new(nil)
52
52
  MessageEvent = Struct.new(:data)
53
+ PingEvent = Struct.new(:data)
54
+ PongEvent = Struct.new(:data)
53
55
  CloseEvent = Struct.new(:code, :reason)
54
56
 
55
57
  ProtocolError = Class.new(StandardError)
@@ -368,12 +368,14 @@ module WebSocket
368
368
 
369
369
  when OPCODES[:ping] then
370
370
  frame(payload, :pong)
371
+ emit(:ping, PingEvent.new(payload))
371
372
 
372
373
  when OPCODES[:pong] then
373
374
  message = Driver.encode(payload, UNICODE)
374
375
  callback = @ping_callbacks[message]
375
376
  @ping_callbacks.delete(message)
376
377
  callback.call if callback
378
+ emit(:pong, PongEvent.new(payload))
377
379
  end
378
380
 
379
381
  emit_message if frame.final and MESSAGE_OPCODES.include?(opcode)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocket-driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-22 00:00:00.000000000 Z
11
+ date: 2017-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket-extensions
@@ -91,7 +91,6 @@ files:
91
91
  - CHANGELOG.md
92
92
  - LICENSE.md
93
93
  - README.md
94
- - examples/tcp_server.rb
95
94
  - ext/websocket-driver/WebsocketMaskService.java
96
95
  - ext/websocket-driver/extconf.rb
97
96
  - ext/websocket-driver/websocket_mask.c
@@ -113,7 +112,7 @@ files:
113
112
  - lib/websocket/http/response.rb
114
113
  - lib/websocket/mask.rb
115
114
  - lib/websocket/websocket_mask.rb
116
- homepage: http://github.com/faye/websocket-driver-ruby
115
+ homepage: https://github.com/faye/websocket-driver-ruby
117
116
  licenses:
118
117
  - MIT
119
118
  metadata: {}
@@ -137,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
136
  version: '0'
138
137
  requirements: []
139
138
  rubyforge_project:
140
- rubygems_version: 2.6.8
139
+ rubygems_version: 2.6.11
141
140
  signing_key:
142
141
  specification_version: 4
143
142
  summary: WebSocket protocol handler with pluggable I/O
@@ -1,28 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'eventmachine'
4
- require 'websocket/driver'
5
- require 'permessage_deflate'
6
-
7
- module Connection
8
- def initialize
9
- @driver = WebSocket::Driver.server(self)
10
- @driver.add_extension(PermessageDeflate)
11
-
12
- @driver.on(:connect) { |e| @driver.start if WebSocket::Driver.websocket? @driver.env }
13
- @driver.on(:message) { |e| @driver.frame(e.data) }
14
- @driver.on(:close) { |e| close_connection_after_writing }
15
- end
16
-
17
- def receive_data(data)
18
- @driver.parse(data)
19
- end
20
-
21
- def write(data)
22
- send_data(data)
23
- end
24
- end
25
-
26
- EM.run {
27
- EM.start_server('127.0.0.1', ARGV[0], Connection)
28
- }