README.md in wamp_client-0.0.9 vs README.md in wamp_client-0.1.0
- old
+ new
@@ -1,6 +1,6 @@
-# WampClient
+# Wamp::Client
[![Gem Version](https://badge.fury.io/rb/wamp_client.svg)](https://badge.fury.io/rb/wamp_client)
[![Circle CI](https://circleci.com/gh/ericchapman/ruby_wamp_client/tree/master.svg?&style=shield&circle-token=92813c17f9c9510c4c644e41683e7ba2572e0b2a)](https://circleci.com/gh/ericchapman/ruby_wamp_client/tree/master)
[![Codecov](https://img.shields.io/codecov/c/github/ericchapman/ruby_wamp_client/master.svg)](https://codecov.io/github/ericchapman/ruby_wamp_client)
@@ -8,10 +8,12 @@
Please use [wamp_rails](https://github.com/ericchapman/ruby_wamp_rails) to integrate this GEM in to RAILS.
## Revision History
+ - v0.1.0:
+ - BREAKING CHANGE - Changed all of the namespaces to be "Wamp::Client"
- v0.0.9:
- Added support for transport override and 'faye-websocket' transport
- Added "on(event)" callback (still support legacy methods)
- Increased Test Coverage for 'Transport' and 'Connection' classes
- v0.0.8:
@@ -63,18 +65,18 @@
#### Creating a connection
A connection can be created as follows
```ruby
-require 'wamp_client'
+require 'wamp/client'
options = {
uri: 'ws://127.0.0.1:8080/ws',
realm: 'realm1',
verbose: true
}
-connection = WampClient::Connection.new(options)
+connection = Wamp::Client::Connection.new(options)
connection.on(:join) do |session, details|
puts "Session Open"
# Register for something
@@ -157,23 +159,23 @@
$ gem install faye-websocket
Override the transport by doing the following:
```ruby
-require 'wamp_client'
+require 'wamp/client'
options = {
uri: 'ws://127.0.0.1:8080/ws',
realm: 'realm1',
proxy: { # See faye-websocket documentation
:origin => 'http://username:password@proxy.example.com',
:headers => {'User-Agent' => 'ruby'}
},
- transport: WampClient::Transport::FayeWebSocket
+ transport: Wamp::Client::Transport::FayeWebSocket
}
-connection = WampClient::Connection.new(options)
+connection = Wamp::Client::Connection.new(options)
# More code
```
Note that the "faye-wesbsocket" transport supports passing in a "proxy" as shown above.
@@ -188,24 +190,24 @@
#### WAMPCRA
To perform WAMP CRA, do the following
```ruby
-require 'wamp_client'
+require 'wamp/client'
options = {
uri: 'ws://127.0.0.1:8080/ws',
realm: 'realm1',
authid: 'joe',
authmethods: ['wampcra']
}
-connection = WampClient::Connection.new(options)
+connection = Wamp::Client::Connection.new(options)
connection.on(:challenge) do |authmethod, extra|
puts 'Challenge'
if authmethod == 'wampcra'
- WampClient::Auth::Cra.sign('secret', extra[:challenge])
+ Wamp::Client::Auth::Cra.sign('secret', extra[:challenge])
else
raise RuntimeError, "Unsupported auth method #{authmethod}"
end
end
@@ -229,11 +231,11 @@
All handlers are called with the following parameters
- args [Array] - Array of arguments
- kwargs [Hash] - Hash of key/value arguments
- details [Hash] - Hash containing some details about the call. Details include
- - session [WampClient::Session] - The session
+ - session [Wamp::Client::Session] - The session
- etc.
Some examples of this are shown below
**lambda**
@@ -259,11 +261,11 @@
- result [Object] - Some object with the result information (depends on the call)
- error [Hash] - Hash containing "error", "args", and "kwargs" if an error occurred
- details [Hash] - Hash containing some details about the call. Details include
- type [String] - The type of message
- - session [WampClient::Session] - The session
+ - session [Wamp::Client::Session] - The session
- etc.
An example of this is shown below
```ruby
@@ -501,13 +503,13 @@
```ruby
handler = lambda do |args, kwargs, details|
raise 'error'
# OR
- raise WampClient::CallError.new('wamp.error', ['some error'], {details: true})
+ raise Wamp::Client::CallError.new('wamp.error', ['some error'], {details: true})
# OR
- WampClient::CallError.new('wamp.error', ['some error'], {details: true})
+ Wamp::Client::CallError.new('wamp.error', ['some error'], {details: true})
end
session.register('com.example.procedure', handler)
```
All 3 of the above examples will return a WAMP Error
@@ -516,11 +518,11 @@
A deferred call refers to a call where the response needs to be asynchronously fetched before it can be returned to the
caller. This is shown below
```ruby
def add(args, kwargs, details)
- defer = WampClient::Defer::CallDefer.new
+ defer = Wamp::Client::Defer::CallDefer.new
EM.add_timer(2) { # Something Async
defer.succeed(args[0]+args[1])
}
defer
end
@@ -529,13 +531,13 @@
Errors are returned as follows
```ruby
def add(args, kwargs, details)
- defer = WampClient::Defer::CallDefer.new
+ defer = Wamp::Client::Defer::CallDefer.new
EM.add_timer(2) { # Something Async
- defer.fail(WampClient::CallError.new('test.error'))
+ defer.fail(Wamp::Client::CallError.new('test.error'))
}
defer
end
session.register('com.example.procedure', method(:add))
```
@@ -557,19 +559,19 @@
**Callee**
```ruby
def add(args, kwargs, details)
- defer = WampClient::Defer::ProgressiveCallDefer.new
+ defer = Wamp::Client::Defer::ProgressiveCallDefer.new
EM.add_timer(2) { # Something Async
- defer.progress(WampClient::CallResult.new([1,2,3]))
+ defer.progress(Wamp::Client::CallResult.new([1,2,3]))
}
EM.add_timer(4) { # Something Async
- defer.progress(WampClient::CallResult.new([4,5,6]))
+ defer.progress(Wamp::Client::CallResult.new([4,5,6]))
}
EM.add_timer(6) { # Something Async
- defer.succeed(WampClient::CallResult.new)
+ defer.succeed(Wamp::Client::CallResult.new)
}
defer
end
session.register('com.example.procedure', method(:add))
```
@@ -608,24 +610,24 @@
# To trigger a custom error, either return something or raise a "CallError"
# else the library will raise a standard error for you
end
def add(args, kwargs, details)
- defer = WampClient::Defer::ProgressiveCallDefer.new
+ defer = Wamp::Client::Defer::ProgressiveCallDefer.new
EM.add_timer(2) { # Something Async
if @interrupts[defer.request].nil?
- defer.progress(WampClient::CallResult.new([1,2,3]))
+ defer.progress(Wamp::Client::CallResult.new([1,2,3]))
end
}
EM.add_timer(4) { # Something Async
if @interrupts[defer.request].nil?
- defer.progress(WampClient::CallResult.new([4,5,6]))
+ defer.progress(Wamp::Client::CallResult.new([4,5,6]))
end
}
EM.add_timer(6) { # Something Async
if @interrupts[defer.request].nil?
- defer.succeed(WampClient::CallResult.new)
+ defer.succeed(Wamp::Client::CallResult.new)
end
@interrupts.delete(request)
}
defer
end
@@ -661,10 +663,10 @@
The *lib/wamp_client/message.rb* file and the *spec/message_spec.rb* file are autogenerated using the script
*scripts/gen_message.rb*. This is done as follows
$ cd scripts
$ ./gen_message.rb
- $ mv message.rb.tmp ../lib/wamp_client/message.rb
- $ mv message_spec.rb.tmp ../spec/message_spec.rb
+ $ mv message.rb.tmp ../lib/wamp/client/message.rb
+ $ mv message_spec.rb.tmp ../spec/wamp/client/message_spec.rb
As I was writing the code for the messages I caught myself cutting and pasting allot and decided these would be
better suited to be autogenerated.