Smack: Getting Started

詳しくは以下の公式ドキュメントを参照するとよいでしょう。

まず中心となるのはXMPPConnectionクラスになる。

namespaceのorg.jivesoftware.smackは省略してあります。

SYNOPSIS
ConnectionConfiguration config = new ConnectionConfiguration(host, port, domain);
XMPPConnection conn = new XMPPConnection(conf);
conn.connect();
conn.login(user, pass);
if (conn.isAuthenticated()) {

}
conn.disconnect();

スタンザの送信は次のようにsendPacketを利用して行うことが出来る。

SYNOPSIS
conn.sendPacket(new Presence(Presence.Type.available, "status", priority, Presence.Mode.available));

Smack: MUC

詳しくは以下の公式ドキュメントを参照するとよいでしょう。

SYNOPSIS
MutiUserChat muc = new MultiUserChat(connection, "roomname@muc.example.org");
muc.create("roomnick");
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
SYNOPSIS
muc.join('nick');
muc.addInvitationRejectionListener(new InvitationRejectionListener(){
  public void invitationDeclined(String invitee, String reason) {}
});
MultiUserChat.addInvitationListener(conn, new InvitationListener(){
  public void invitationReceived(Connection conn, String room, String inviter, String reason, String password) {
        MultiUserChat.decline(conn, room, inviter, "busy");
  }
});