em-websocket-client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a87cb48e8fd3e317eec9a00a887c165fd5b1ba31
4
+ data.tar.gz: d56ac8a767faab371c2eb347e2ca337ea327c9ee
5
+ SHA512:
6
+ metadata.gz: 4d651353c8fbebfb87068536d7cb5d40960551d2ae6ccdda2d189dba5779edfbcc43fd13b286bb392b0e202e007269f778fc0b959f08880aec74f388e4d14ae0
7
+ data.tar.gz: bcae5a4dc45a43e09a878fe064f43e12ae1c553bf17797499441ff026ac05fd22db0f23a069e23c0038ab5e24fd713a9ef367d676c16a86bc929ff4875237465
data/Gemfile CHANGED
@@ -1,12 +1,11 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem "eventmachine"
4
- gem "libwebsocket"
4
+ gem "websocket"
5
5
 
6
6
  group :development do
7
7
  gem "rspec", "~> 2.3.0"
8
8
  gem "yard", "~> 0.6.0"
9
- gem "bundler", "~> 1.0.0"
10
- gem "jeweler", "~> 1.6.4"
11
- gem "rcov", ">= 0"
9
+ gem "bundler", "~> 1.3.0"
10
+ gem "jeweler", "~> 1.8.0"
12
11
  end
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  This gem implements a simple websocket client inside EventMachine.
4
4
  This might be useful for testing web socket servers or consuming
5
5
  WebSocket APIs. In particular it supports the
6
- [hixie-76](http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76)
6
+ [RFC6455](http://tools.ietf.org/html/rfc6455)
7
7
  version of the protocol, which is also implemented in Chrome and
8
8
  Safari. At this time, the wss (WebSocket over SSL) protocol is not
9
9
  supported.
@@ -24,10 +24,10 @@ EM.run do
24
24
  conn.errback do |e|
25
25
  puts "Got error: #{e}"
26
26
  end
27
-
27
+
28
28
  conn.stream do |msg|
29
29
  puts "<#{msg}>"
30
- if msg == "done"
30
+ if msg.data == "done"
31
31
  conn.close_connection
32
32
  end
33
33
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{em-websocket-client}
8
- s.version = "0.1.1"
7
+ s.name = "em-websocket-client"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Micah Wylde"]
12
- s.date = %q{2011-08-02}
13
- s.description = %q{A WebSocket client implementation for EventMachine}
14
- s.email = %q{mwylde@wesleyan.edu}
12
+ s.date = "2013-10-12"
13
+ s.description = "A WebSocket client implementation for EventMachine"
14
+ s.email = "mwylde@wesleyan.edu"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.md"
@@ -27,40 +27,37 @@ Gem::Specification.new do |s|
27
27
  "em-websocket-client.gemspec",
28
28
  "lib/em-websocket-client.rb"
29
29
  ]
30
- s.homepage = %q{http://github.com/mwylde/em-websocket-client}
30
+ s.homepage = "http://github.com/mwylde/em-websocket-client"
31
31
  s.licenses = ["MIT"]
32
32
  s.require_paths = ["lib"]
33
- s.rubygems_version = %q{1.6.2}
34
- s.summary = %q{EventMachine WebSocket Client}
33
+ s.rubygems_version = "2.0.3"
34
+ s.summary = "EventMachine WebSocket Client"
35
35
 
36
36
  if s.respond_to? :specification_version then
37
- s.specification_version = 3
37
+ s.specification_version = 4
38
38
 
39
39
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
40
40
  s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
41
- s.add_runtime_dependency(%q<libwebsocket>, [">= 0"])
41
+ s.add_runtime_dependency(%q<websocket>, [">= 0"])
42
42
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
43
43
  s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
44
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
45
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
46
- s.add_development_dependency(%q<rcov>, [">= 0"])
44
+ s.add_development_dependency(%q<bundler>, ["~> 1.3.0"])
45
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.0"])
47
46
  else
48
47
  s.add_dependency(%q<eventmachine>, [">= 0"])
49
- s.add_dependency(%q<libwebsocket>, [">= 0"])
48
+ s.add_dependency(%q<websocket>, [">= 0"])
50
49
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
51
50
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
52
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
53
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
54
- s.add_dependency(%q<rcov>, [">= 0"])
51
+ s.add_dependency(%q<bundler>, ["~> 1.3.0"])
52
+ s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
55
53
  end
56
54
  else
57
55
  s.add_dependency(%q<eventmachine>, [">= 0"])
58
- s.add_dependency(%q<libwebsocket>, [">= 0"])
56
+ s.add_dependency(%q<websocket>, [">= 0"])
59
57
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
60
58
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
61
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
62
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
63
- s.add_dependency(%q<rcov>, [">= 0"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.3.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
64
61
  end
65
62
  end
66
63
 
@@ -1,33 +1,6 @@
1
+ require 'eventmachine'
1
2
  require 'uri'
2
- require 'libwebsocket'
3
-
4
- # Monkey patch libwebsocket to support parameters in URLs
5
- module LibWebSocket
6
- class URL
7
- def parse(string)
8
- return nil unless string.is_a?(String)
9
-
10
- uri = Addressable::URI.parse(string)
11
-
12
- scheme = uri.scheme
13
- return nil unless scheme
14
-
15
- self.secure = true if scheme.match(/ss\Z/m)
16
-
17
- host = uri.host
18
- host = '/' unless host && host != ''
19
- self.host = host
20
- self.port = uri.port.to_s if uri.port
21
-
22
- request_uri = uri.path
23
- request_uri = '/' unless request_uri && request_uri != ''
24
- request_uri += "?" + uri.query if uri.query
25
- self.resource_name = request_uri
26
-
27
- return self
28
- end
29
- end
30
- end
3
+ require 'websocket'
31
4
 
32
5
  module EventMachine
33
6
  class WebSocketClient < Connection
@@ -44,36 +17,37 @@ module EventMachine
44
17
 
45
18
  def post_init
46
19
  @handshaked = false
47
- @frame = LibWebSocket::Frame.new
20
+ @frame = ::WebSocket::Frame::Incoming::Client.new
48
21
  end
49
22
 
50
23
  def connection_completed
51
- @hs = LibWebSocket::OpeningHandshake::Client.new(:url => @url)
24
+ @connect.yield if @connect
25
+ @hs = ::WebSocket::Handshake::Client.new(:url => @url)
52
26
  send_data @hs.to_s
53
27
  end
54
28
 
55
29
  def stream &cb; @stream = cb; end
30
+ def connected &cb; @connect = cb; end
56
31
  def disconnect &cb; @disconnect = cb; end
57
-
32
+
58
33
  def receive_data data
59
34
  if !@handshaked
60
- result = @hs.parse data
61
- fail @hs.error unless result
62
-
63
- if @hs.done?
35
+ @hs << data
36
+ if @hs.finished?
64
37
  @handshaked = true
65
38
  succeed
66
39
  end
67
40
  else
68
- @frame.append(data)
41
+ @frame << data
69
42
  while msg = @frame.next
70
43
  @stream.call(msg) if @stream
71
44
  end
72
45
  end
73
46
  end
74
47
 
75
- def send_msg s
76
- frame = LibWebSocket::Frame.new(s)
48
+ def send_msg(s, args={})
49
+ type = args[:type] || :text
50
+ frame = ::WebSocket::Frame::Outgoing::Client.new(:data => s, :type => type, :version => @hs.version)
77
51
  send_data frame.to_s
78
52
  end
79
53
 
metadata CHANGED
@@ -1,105 +1,107 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: em-websocket-client
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Micah Wylde
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-08-02 00:00:00 -07:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
11
+ date: 2013-10-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
17
14
  name: eventmachine
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
24
20
  type: :runtime
25
21
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: libwebsocket
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: websocket
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
39
42
  name: rspec
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
43
45
  - - ~>
44
- - !ruby/object:Gem::Version
46
+ - !ruby/object:Gem::Version
45
47
  version: 2.3.0
46
48
  type: :development
47
49
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.3.0
55
+ - !ruby/object:Gem::Dependency
50
56
  name: yard
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
54
59
  - - ~>
55
- - !ruby/object:Gem::Version
60
+ - !ruby/object:Gem::Version
56
61
  version: 0.6.0
57
62
  type: :development
58
63
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.0
69
+ - !ruby/object:Gem::Dependency
61
70
  name: bundler
62
- requirement: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
65
73
  - - ~>
66
- - !ruby/object:Gem::Version
67
- version: 1.0.0
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.0
68
76
  type: :development
69
77
  prerelease: false
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.0
83
+ - !ruby/object:Gem::Dependency
72
84
  name: jeweler
73
- requirement: &id006 !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
76
87
  - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 1.6.4
79
- type: :development
80
- prerelease: false
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: rcov
84
- requirement: &id007 !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.8.0
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *id007
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 1.8.0
93
97
  description: A WebSocket client implementation for EventMachine
94
98
  email: mwylde@wesleyan.edu
95
99
  executables: []
96
-
97
100
  extensions: []
98
-
99
- extra_rdoc_files:
101
+ extra_rdoc_files:
100
102
  - LICENSE.txt
101
103
  - README.md
102
- files:
104
+ files:
103
105
  - .document
104
106
  - .rspec
105
107
  - Gemfile
@@ -109,36 +111,28 @@ files:
109
111
  - VERSION
110
112
  - em-websocket-client.gemspec
111
113
  - lib/em-websocket-client.rb
112
- has_rdoc: true
113
114
  homepage: http://github.com/mwylde/em-websocket-client
114
- licenses:
115
+ licenses:
115
116
  - MIT
117
+ metadata: {}
116
118
  post_install_message:
117
119
  rdoc_options: []
118
-
119
- require_paths:
120
+ require_paths:
120
121
  - lib
121
- required_ruby_version: !ruby/object:Gem::Requirement
122
- none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: -3387102389269862192
127
- segments:
128
- - 0
129
- version: "0"
130
- required_rubygems_version: !ruby/object:Gem::Requirement
131
- none: false
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- version: "0"
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
136
132
  requirements: []
137
-
138
133
  rubyforge_project:
139
- rubygems_version: 1.6.2
134
+ rubygems_version: 2.0.3
140
135
  signing_key:
141
- specification_version: 3
136
+ specification_version: 4
142
137
  summary: EventMachine WebSocket Client
143
138
  test_files: []
144
-