Coder Social home page Coder Social logo

spectra / xmpp4r-observable Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 1.0 107 KB

A Jabber client library following a custom version of Ruby's Observable pattern, with support to XMPP PubSub

Home Page: http://www.nardol.org/

License: GNU General Public License v2.0

Ruby 100.00%

xmpp4r-observable's Introduction

= Name

Jabber::Observable - An easy to use, observable Jabber client library with
PubSub support.

= Synopsis

  # Send a message to a friend, asking for authorization if necessary:
  im = Jabber::Observable.new("[email protected]", "password")
  im.deliver("[email protected]", "Hey there friend!")

  # Register a new observer for incoming messages:
  observer = SomeObserverClass.new
  im.add_observer(:message, observer)

  # Unregister the observer:
  im.delete_observer(:message, observer)

  # Send an authorization request to a user:
  im.subs.add("[email protected]")

  # Remove a user from your contact list:
  im.subs.remove("[email protected]")

  # Create a PubSub node:
  im.pubsub.create_node("/mynode")

  # Publishing something to the node:
  im.pubsub.publish_simple_item("/mynode", "body", "something")

  # Subscribing to a node:
  im.pubsub.subscribe_to("/othernode")

  # Get my nodes:
  im.pubsub.my_nodes

  # Get my subscriptions:
  im.pubsub.subscriptions

  # Register an observer for events on nodes I subscribed to:
  im.add_observer(:event, observer)

  # Attach an auto-observer (this gets everything that can be observed and
  # makes it available in queues):
  im.attach_auto_observer

  # Receive messages via the auto-observer
  if im.auto.received?(:message)
    im.auto.received(:message).each do |msg|
      puts msg.body
    end
  end

  # Dettach the auto-observer
  im.dettach_auto_observer

  # See the Jabber::Observable documentation for more information.

= Description

Jabber::Observable is intended to make Jabber client programming simple and
poweful. This library exposes common tasks in messaging, subscription handling
and Publication and Subscription (PubSub) of nodes using a variation of Ruby's
builtin Observer pattern, lowering the need to monitor queues using threads.
For those that still want to use threads, there's an auto-observer that can be
easily attached.

= Copyright

Jabber::Observable - An observable Jabber client library with PubSub support.
Copyright (C) 2008-2009 Pablo Lorenzzoni <[email protected]>.

Based on and inspired by: Jabber::Simple by Blaine Cook <[email protected]>.

Jabber::Observable is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.

Jabber::Observable is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
details.

You should have received a copy of the GNU General Public License along with
Jabber::Observable; if not, write to the Free Software Foundation, Inc., 51
Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.