websocket-client-simple 0.0.9 → 0.1.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: 4c77561031da6ed2b7c158b90a359714d86c9c4c
4
- data.tar.gz: 5e3db2931d4fab5c52438b3dc4373ba69b604bac
3
+ metadata.gz: b4ea337a582d882d5b994ae917ead5f8bb7d8366
4
+ data.tar.gz: c5ba071b095d13b4d2e0a94b5d005f5bb0d40e83
5
5
  SHA512:
6
- metadata.gz: 515e8e4fe7f48323186324b6271a25febe05a6b0e52f6e132fef21ff4caaf81dc7c7130ff1eb45c5c08aa34d89778f183ed61ce4ec51a991cba8812c3e5a58e1
7
- data.tar.gz: 6b681526e86e0812d3c4bfdac5b23acac4584b367fc9cafae92915bb9798b4aae719d9d074b958fe5852612fe0d3184cdf54c25d8b0696308e433d2c9499a74c
6
+ metadata.gz: ce374970d37e555925969ef5bb6c126c5020e0fdd3743d6a996604802b1751620819984c40efc7bb8d5749fc25e23930c5f9ec8f88ad57577623a423cb3d3773
7
+ data.tar.gz: 60453f1fcb3df824ffcbc88f099d38dbb2576c8a4b14a208d44ce2157bed2b3f2f23d0236e041410b62188c099d9f46506ac5d742a445b1225b557fe45397210
@@ -2,4 +2,3 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - jruby-head
@@ -1,3 +1,8 @@
1
+ === 0.1.0 2014-05-08
2
+
3
+ * add accessor Client#handshake #5
4
+ * bugfix socket reading
5
+
1
6
  === 0.0.9 2014-04-03
2
7
 
3
8
  * emit "error" in receive thread
@@ -8,13 +8,13 @@ module WebSocket
8
8
 
9
9
  class Client
10
10
  include EventEmitter
11
- attr_reader :url
11
+ attr_reader :url, :handshake
12
12
 
13
13
  def initialize(url)
14
14
  @url = url
15
15
  uri = URI.parse url
16
16
  @socket = TCPSocket.new(uri.host, uri.port || 80)
17
- @hs = ::WebSocket::Handshake::Client.new :url => url
17
+ @handshake = ::WebSocket::Handshake::Client.new :url => url
18
18
  @handshaked = false
19
19
  frame = ::WebSocket::Frame::Incoming::Client.new
20
20
  @closed = false
@@ -26,10 +26,10 @@ module WebSocket
26
26
  @thread = Thread.new do
27
27
  while !@closed do
28
28
  begin
29
- recv_data = @socket.getc
30
- if !@handshaked
31
- @hs << recv_data
32
- if @hs.finished?
29
+ next unless recv_data = @socket.getc
30
+ unless @handshaked
31
+ @handshake << recv_data
32
+ if @handshake.finished?
33
33
  @handshaked = true
34
34
  emit :open
35
35
  end
@@ -45,13 +45,13 @@ module WebSocket
45
45
  end
46
46
  end
47
47
 
48
- @socket.write @hs.to_s
48
+ @socket.write @handshake.to_s
49
49
  end
50
50
 
51
51
  def send(data, opt={:type => :text})
52
52
  return if !@handshaked or @closed
53
53
  type = opt[:type]
54
- frame = ::WebSocket::Frame::Outgoing::Client.new(:data => data, :type => type, :version => @hs.version)
54
+ frame = ::WebSocket::Frame::Outgoing::Client.new(:data => data, :type => type, :version => @handshake.version)
55
55
  begin
56
56
  @socket.write frame.to_s
57
57
  rescue Errno::EPIPE => e
@@ -70,7 +70,7 @@ module WebSocket
70
70
  end
71
71
 
72
72
  def open?
73
- !@closed
73
+ @handshake.finished? and !@closed
74
74
  end
75
75
 
76
76
  end
@@ -1,7 +1,7 @@
1
1
  module WebSocket
2
2
  module Client
3
3
  module Simple
4
- VERSION = "0.0.9"
4
+ VERSION = "0.1.0"
5
5
  end
6
6
  end
7
7
  end
@@ -33,7 +33,9 @@ class TestWebSocketClientSimple < MiniTest::Test
33
33
  EM::add_timer 1 do
34
34
  url = "ws://localhost:#{port}"
35
35
  client1 = WebSocket::Client::Simple.connect url
36
+ assert_equal client1.open?, false
36
37
  client2 = WebSocket::Client::Simple.connect url
38
+ assert_equal client2.open?, false
37
39
 
38
40
  client1.on :message do |msg|
39
41
  res1.push msg
@@ -58,6 +60,8 @@ class TestWebSocketClientSimple < MiniTest::Test
58
60
  end
59
61
 
60
62
  EM::add_timer 3 do
63
+ assert_equal client1.open?, true
64
+ assert_equal client2.open?, true
61
65
  client1.close
62
66
  client2.close
63
67
  EM::stop_event_loop
@@ -65,12 +69,12 @@ class TestWebSocketClientSimple < MiniTest::Test
65
69
  end
66
70
  }
67
71
 
68
- assert msgs.size == res1.size
69
- assert msgs.size == res2.size
72
+ assert_equal msgs.size, res1.size
73
+ assert_equal msgs.size, res2.size
70
74
 
71
75
  msgs.each_with_index do |msg,i|
72
- assert msg == res1[i].to_s
73
- assert msg == res2[i].to_s
76
+ assert_equal msg, res1[i].to_s
77
+ assert_equal msg, res2[i].to_s
74
78
  end
75
79
 
76
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocket-client-simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler