websocket-driver 0.6.5-java → 0.7.0-java

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
- SHA1:
3
- metadata.gz: dcd1cd3f4fbfa7dcdcd3ec1a5190165abc4072bb
4
- data.tar.gz: 71104f9f20b82cbd2677ed13cdeb9c71790a26aa
2
+ SHA256:
3
+ metadata.gz: 56ae9057b4d473ec55363da2309322999d71f5be9e457d4d94cc6b40c0bbaac5
4
+ data.tar.gz: 2cb85005552be8596408bba185073e008734dc0b0240fe7382690212a5818eb6
5
5
  SHA512:
6
- metadata.gz: 7bfe24e050a4f5b342328af911fbdfe260c0e22ec933f2b56bae8657dc50a08ce77c6c3622be18432dc0da44a9eb2be67df494402c9736029864a10f0725ea6f
7
- data.tar.gz: bb1f533ae8da678e7d81142fdc65a4d38e4835782b859183919ed97568636e58c2f1feb289b0e40ce67e7469a0990bd42297fb19680dbcebd9ee07ae38b045d3
6
+ metadata.gz: 90ffb3c5ae767a18488af3c42ce24656a8ac1bf799cb7ed37f6dda09b27f438c25f8db01d8507793007d8940354c9800b2363c4dabf1636136f515af50e6b574
7
+ data.tar.gz: 7842519e1eb00bdff05c1dcc5d6b916430c82d9becf54ac21eec4bee482c234642472ee3b624d4d4c59ee48c0d7c930e108a32f33ba281a4a81bab515cd474ed
data/CHANGELOG.md CHANGED
@@ -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)
Binary file
metadata CHANGED
@@ -1,23 +1,23 @@
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: java
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
15
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.1.0
20
- requirement: !ruby/object:Gem::Requirement
20
+ version_requirements: !ruby/object:Gem::Requirement
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
@@ -26,12 +26,12 @@ dependencies:
26
26
  type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eventmachine
29
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- requirement: !ruby/object:Gem::Requirement
34
+ version_requirements: !ruby/object:Gem::Requirement
35
35
  requirements:
36
36
  - - ">="
37
37
  - !ruby/object:Gem::Version
@@ -40,12 +40,12 @@ dependencies:
40
40
  type: :development
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: permessage_deflate
43
- version_requirements: !ruby/object:Gem::Requirement
43
+ requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- requirement: !ruby/object:Gem::Requirement
48
+ version_requirements: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
@@ -54,12 +54,12 @@ dependencies:
54
54
  type: :development
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake-compiler
57
- version_requirements: !ruby/object:Gem::Requirement
57
+ requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.8.0
62
- requirement: !ruby/object:Gem::Requirement
62
+ version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
@@ -68,12 +68,12 @@ dependencies:
68
68
  type: :development
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- version_requirements: !ruby/object:Gem::Requirement
71
+ requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
- requirement: !ruby/object:Gem::Requirement
76
+ version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
@@ -90,7 +90,6 @@ files:
90
90
  - CHANGELOG.md
91
91
  - LICENSE.md
92
92
  - README.md
93
- - examples/tcp_server.rb
94
93
  - ext/websocket-driver/WebsocketMaskService.java
95
94
  - ext/websocket-driver/extconf.rb
96
95
  - ext/websocket-driver/websocket_mask.c
@@ -113,7 +112,7 @@ files:
113
112
  - lib/websocket/mask.rb
114
113
  - lib/websocket/websocket_mask.rb
115
114
  - lib/websocket_mask.jar
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.4.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
- }