XMPP Client
- Add romeo and exml to your list of dependencies in
mix.exs
:
def deps do
[{:romeo, "~> 0.7"}]
end
- Ensure romeo is started before your application:
def application do
[applications: [:romeo]]
end
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 is available on hexdocs
It follows the great tradition to use characters of William Shakespeare's Romeo and Juliet in the XMPP specifications.
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.
Image credit: Henri-Pierre Picou [Public domain], via Wikimedia Commons