websocketio 0.0.1 → 0.0.2

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: 9d9761e5661e390bd615bd8f6f195c93813f5c06
4
- data.tar.gz: cffb0529922148010360e0f89db9d5e5064fd005
3
+ metadata.gz: 15650d9613c290d249e87573fc8de5a835edbab6
4
+ data.tar.gz: 878f231cd511cd75abadfab7327fa87bd98d6fc0
5
5
  SHA512:
6
- metadata.gz: f34470bc4e66bbff0ed97fb7b1dde924e797fe8afeb6c942a9d878e9df41a3dd7c39583c1e2bc5f3195982163eb672d1107c67e35e50b5ce3df84146b66b8914
7
- data.tar.gz: 1f8bda924a87be3f233240e7d6dcc822fa32a7a60356ffff09a39840bf91d608d95885e3f54039852bef6662f24439d7df664b6ee2695ef53276a4bf7324a553
6
+ metadata.gz: f488a1b33efc880840ec60f7bd6f71a48333dbe1f1b7382b4caa98f2beddb964d25501c2ac7223371d5bf7ecfcc983b29f295b9ff95706f524e04a88b2e71ace
7
+ data.tar.gz: 79f4afd3445949c0af4adaa7072f1a4034b71f196b3fd831ff8b00e53aaacc783cea3cba8b10d3b8138d74ff193bc0b8c677d774932661e1e791b1171da30bfd
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 0.0.2
2
+
3
+ * arg `options[:write_type]` is available at initialize method.
4
+
5
+ ## 0.0.1
6
+
7
+ * Initial release
data/README.md CHANGED
@@ -39,7 +39,7 @@ while c = websocket.read(1) do
39
39
  end
40
40
  ```
41
41
 
42
- ### new(socket, handshake\_args) -> WebSocketIO::Client
42
+ ### new(socket, handshake\_args, options = {}) -> WebSocketIO::Client
43
43
  #### socket
44
44
 
45
45
  It requires a connected socket object.
@@ -51,6 +51,12 @@ When you want to connect over proxy, you may use [ruby-proxifier](https://github
51
51
  Parameters for WebSocket handshaking.
52
52
  This arg is given to `WebSocket::Handshake::Client.new` which is defined at [websocket-ruby](https://github.com/imanel/websocket-ruby#client-handshake).
53
53
 
54
+ #### options[:write\_type]
55
+
56
+ Type (opcode) of WebSocket frame sent by this object.
57
+ [Keys in `FRAME\_TYPE` defined at websocket-ruby](https://github.com/imanel/websocket-ruby/blob/master/lib/websocket/frame/handler/handler03.rb#L9) are available.
58
+ Default is `:text`.
59
+
54
60
  ## Implemented
55
61
 
56
62
  * WebSocketIO::Client
@@ -7,11 +7,14 @@ require 'forwardable'
7
7
  module WebSocketIO
8
8
  class Client
9
9
  extend Forwardable
10
+ attr_reader :socket
10
11
 
11
12
  def_delegators :@filtered_socket, :read, :getc
12
13
 
13
- def initialize(socket, handshake_args)
14
- @socket = socket
14
+ def initialize(socket, handshake_args, options = {})
15
+ @socket = socket
16
+ @options = options
17
+
15
18
  @handshake = WebSocket::Handshake::Client.new(handshake_args)
16
19
  @socket.write @handshake.to_s
17
20
  until @handshake.finished? do
@@ -45,7 +48,7 @@ module WebSocketIO
45
48
  def send_frame(params)
46
49
  params = {
47
50
  data: nil,
48
- type: :text,
51
+ type: @options[:write_type] || :text,
49
52
  version: @handshake.version
50
53
  }.merge(params)
51
54
  frame = WebSocket::Frame::Outgoing::Client.new(params)
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module WebSocketIO
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocketio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi Horiuchi
@@ -131,6 +131,7 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - ".gitignore"
133
133
  - ".travis.yml"
134
+ - CHANGELOG.md
134
135
  - Gemfile
135
136
  - LICENSE.txt
136
137
  - README.md