https://github.com/sourcey/symple-client-ruby
Symple client for Ruby
https://github.com/sourcey/symple-client-ruby
Last synced: about 1 year ago
JSON representation
Symple client for Ruby
- Host: GitHub
- URL: https://github.com/sourcey/symple-client-ruby
- Owner: sourcey
- Created: 2014-04-01T06:30:27.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-04-06T05:43:49.000Z (about 12 years ago)
- Last Synced: 2025-01-12T02:42:11.088Z (over 1 year ago)
- Language: Ruby
- Size: 121 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Symple Ruby Client
The Symple client module for Ruby which enables one to send Symple messages from a Ruby app to the server using the intermediary redis instance.
## What is Symple?
Symple is a presence and messaging protocol which is semantically similar to XMPP, except that it is unrestrictive and vastly simplified, and it uses JSON instead of XML for encoding messages. Symple also has a C++ client which makes it ideas for messaging and remoting between desktop, mobile and browser clients.
## How to use it
1. Clone the `symple-ruby-client`
2. Simply `require` the `symple.rb` file in your Ruby app
3. Call `broadcast`, `broadcast_user` or `broadcast_group` to send a JSON serialized object to peers.
## Examples
Here is an example of using Symple in a Rails app. Lets say we have an Event model, and we want to broadcast the object to all connected peers in the group when a new Event is created:
```ruby
class Event < ActiveRecord::Base
belongs_to :user
after_create :symple_broadcast
def symple_broadcast
Symple.broadcast_group(self.user.group_id, {
name: self.name, # name of the event
type: self.class.name, # the name of the object being serialized
from: "#{self.user.username}@#{self.user.group_id}", # sender symple address
data: self # pass the instance to be serialized using to_json
})
end
end
```
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## Contact
For more information please check out the Symple homepage: http://sourcey.com/symple/
If you have a bug or an issue then please use our new Github issue tracker: https://github.com/sourcey/symple-client-ruby/issues