Sha256: c40cd2ede055d1dc39f4aaadfa13afb83d0bad637d69eb66689d181d8da3e521

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

# Crossbar HTTP

[![Gem Version](https://badge.fury.io/rb/crossbar-http.svg)](https://badge.fury.io/rb/crossbar-http)

Module that provides methods for accessing Crossbar.io HTTP Bridge Services

## Revision History

  - v0.1.0:
    - Initial version
  - v0.1.1:
    - Fixed typos in README
    - Added support for https (I didn't know the library I was using didn't)

## Installation

``` ruby
gem 'crossbar-http'
```

## Usage

### Call
To call a Crossbar HTTP bridge, do the following

``` ruby
client = Crossbar::HTTP::Client.new("http://127.0.0.1/call")
result = client.call("com.example.add", 2, 3, offset: 10)
```
    
This will call the following method

``` python
def onJoin(self, details):
        
    def add_something(x, y, offset=0):
        print "Add was called"
        return x+y+offset

    self.register(add_something, "com.example.add")
```
        
### Publish
To publish to a Crossbar HTTP bridge, do the following

``` ruby
client = Crossbar::HTTP::Client.new("http://127.0.0.1/publish")
result = client.publish("com.example.event", event: "new event")
```
    
The receiving subscription would look like

``` python
def onJoin(self, details):
        
    def subscribe_something(event=None, **kwargs):
        print "Publish was called with event %s" % event

    self.subscribe(subscribe_something, "com.example.event")
```

### Key/Secret
For bridge services that have a key and secret defined, simply include the key and secret in the instantiation of the
client.

``` ruby
client = Crossbar::HTTP::Client.new("http://127.0.0.1/publish", key: "key", secret: "secret")
```

## Contributing
To contribute, fork the repo and submit a pull request.

## Testing
TODO

##License
MIT

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crossbar-http-0.1.1 README.md