Skip to content

scrogson/romeo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Romeo

XMPP Client

Build Status Coverage Status

Installation

  1. Add romeo to your list of dependencies in mix.exs:
def deps do
  [{:romeo, "~> 0.7"}]
end
  1. Ensure romeo is started before your application:
def application do
  [applications: [:romeo]]
end

Usage

alias Romeo.Stanza
alias Romeo.Connection, as: Conn
alias Romeo.Roster

# Minimum configuration options
opts = [jid: "[email protected]", password: "iL0v3JuL137"]

# Start the client
{:ok, pid} = Conn.start_link(opts)

# Send presence to the server
:ok = Conn.send(pid, Stanza.presence)

# Request your roster
:ok = Conn.send(pid, Stanza.get_roster)

# Join a chat room
:ok = Conn.send(pid, Stanza.join("[email protected]", "romeo"))

# Send a message to the room
msg = "See how she leans her cheek upon her hand! " <>
      "O that I were a glove upon that hand, that " <>
      "I might touch that cheek!"
:ok = Conn.send(pid, Stanza.groupchat("[email protected]", msg))

# Get roster items as tuple of %Romeo.Roster.Items{} struct
items = Roster.items(pid)

# Add jid to roster
:ok = Roster.add(pid, "[email protected]")

# Remove jid from roster
:ok = Roster.remove(pid, "[email protected]")

Documentation

Documentation is available on hexdocs

Naming

It follows the great tradition to use characters of William Shakespeare's Romeo and Juliet in the XMPP specifications.

License

The MIT License (MIT)

Copyright (c) 2015 Sonny Scroggin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Romeo and Juliet Image credit: Henri-Pierre Picou [Public domain], via Wikimedia Commons