Scala/Akka XMPP client library
Scala
Switch branches/tags
Nothing to show
Latest commit 8fc4d90 Nov 28, 2013 @blt blt Merge pull request #6 from bitdeli-chef/master
Add a Bitdeli Badge to README

README.md

Barkety - An Akka compatible XMPP client library.

While the Apache Camel project has an xmpp component and though Jive Software's Smack is ubiquitous neither fulfill my desires:

  • Convenient roster management,
  • supervision hierarchy ready,
  • and actor-level isolation of state management.

Akka's bindings to camel-xmpp provide the last two and plain Smack allows only the first point.

Usage

The tippy-top of the supervision hierarchy is ChatSupervisor. It understands CreateChat(partner:JID) messages and will reply back with an ActorRef to a Chatter actor. You must send this actor RegisterParent(ref:ActorRef) in order to route inbound messages to another actor. OutboundMessage(msg:String) will send a message to the partner connected by the Chatter.

By default, all chats are preceded by roster subscription invitations.

import us.troutwine.barkety._
import akka.actor.Actor.actorOf
import akka.actor.{Actor,ActorRef}

class Acty(child:ActorRef) extends Actor {
  child ! RegisterParent(self)

  def receive = {
    case InboundMessage(msg:String) => println(msg)
  }
}

object Main extends Application {
  val jid = JID("barketyTest@jabber.org")
  val chatsup = actorOf(new ChatSupervisor(jid, "123456")).start
  (chatsup !! CreateChat(JID("troutwine@jabber.org"))) match {
    case Some(chatter) =>
      actorOf(new Acty(chatter)).start
      chatter ! OutboundMessage("Hi, you!")
    case None =>
  }
}

Bitdeli Badge