Project

ahoy

0.01
No commit activity in last 3 years
No release in over 3 years
Serverless Messaging using DNSDS/mDNS, XMPP, and Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.3.1
= 0.5
 Project Readme

Ahoy¶ ↑

Serverless Messaging using Bonjour/DNSDS/mDNS, XMPP, and Ruby

Wha?

In simpler terms, this is a library for sending messages to iChat (or Adium, Pidgin, etc) using the Bonjour chat protocol.

The Bonjour chat protocol is pretty much XMPP with the presence and server parts ripped out and replaced Bonjour (DNS Service Discovery and multicast DNS). Like standard XMPP while mainly used as for instant messaging, there is nothing stopping you for using it for a more generic messaging system, a presence system or interprocess communication.

Ahoy isn’t much more than a wrapper with a nice API around the dnssd and xmpp4r gems.

Example:

require 'rubygems'
require 'ahoy'

user = Ahoy::User.new("mat")
user.sign_in

sleep 1                               # wait for the contact list to populate

first_contact = user.contacts.first   # find someone to talk to

chat = user.chat(first_contact)       # open a chat with them

chat.send("We come in peace.")        # send a message

puts chat.receive                     # blocks until we get a response

chat.close

Along with the blocking Chat#receive method to receive replies, there is an on_reply method that takes a callback. This method returns immediately, and the block is only called when there is a reply, and can be used like so

require 'rubygems'
require 'ahoy'

user = Ahoy::User.new("mat")
user.sign_in
sleep 1
chat = user.chat(user.contacts.first)

chat.on_reply do |reply|
  puts reply
end

chat.send("hello")

# do something while we wait for a reply
loop do
  sleep 1
end

Messages can be formatted using markdown, simply set Chat#use_markdown (or Ahoy.use_markdown for the global default). Ahoy will use any of the following markdown processors, in order of preference: rdiscount, kramdown, maruku, bluecloth.

The current use case is to send a message to a team of developers when a deploy script is run, there is a simplified interface for this:

require 'rubygems'
require 'ahoy/broadcast'

user = Ahoy::User.new("Dr. Nick")
cast = Ahoy::Broadcast.new(user)

cast.send("Hi, everybody!")
cast.close