Ramp
¶ ↑
Ramp
is AMP protocol implementation in Ruby language. AMP is a very simple message passing and RPC protocol. for more information take a look at here.
Installation¶ ↑
As you may know already installing ruby gems it quite easy:
$ gem install ramp
Isn’t it easy ?
Usage¶ ↑
As every thing else about Ramp
, its usage is easy too :P At first you should be familiar with AMP protocol a little, AMP protocol usa Commands as its RPC units and you should define your own Command subclass. Let see an example:
require 'ramp' class Event < Ramp::Command command "Events" arguments ( {name: Ramp::Fields::StringField, sender: Ramp::Fields::StringField, kwargs: Ramp::Fields::JsonField} ) responses ( {status: Ramp::Fields::IntegerField} ) end
Ok, let’s talk a bit more about the example class. As your can see the Event class is a subclass of Ramp::Command class. and we specify a command for our class by using command class method. Also you should specify the command arguments and responses like above.
That is all we need, now we can run the remote command easily like:
requre 'ramp' rempte = Ramp::AmpClient.new 'localhost', 8888, :async => false remote.call_remote(Event, sender: "me", name: "something", kwargs: {:foo => "bar"})
That’s all. for more information about take a look at _Ramp::AMPClient class.
- Note
-
Remember that Commands should have the same signature as they have on remote server.
Credit¶ ↑
- Author
-
Dave Thomas (lxsameer@gnu.org)
- Copyright
-
Copyright © 2012 Yellowen Inc
- License
-
Distributes under the term of GPLv3