こんにちは、gtalk facebook などに接続できるチャット クライアントを開発する予定です...openfire と共に smack API を使用することにしました..
しかし、openfire サーバーでの使用方法については、ほとんどガイダンスが必要ありません。
また、openfire は、ログイン ボックスのチャット ウィンドウなどの基本的な UI を提供しますか?
openfire で smack をプラグまたは使用する方法を知る必要があります
ありがとう:)
こんにちは、gtalk facebook などに接続できるチャット クライアントを開発する予定です...openfire と共に smack API を使用することにしました..
しかし、openfire サーバーでの使用方法については、ほとんどガイダンスが必要ありません。
また、openfire は、ログイン ボックスのチャット ウィンドウなどの基本的な UI を提供しますか?
openfire で smack をプラグまたは使用する方法を知る必要があります
ありがとう:)
openfire を設定してから、Smack が提供するドキュメントを参照してください。分かりやすい例が載っています。参考までに、openfire は gtalk では正常に動作しますが、facebook では非常に遅くなります。
サンプルコード:-
ConnectionConfiguration config = new ConnectionConfiguration(host, 5222);
XMPPConnection connection = new XMPPConnection(config);
connection.connect();
connection.login(user_name, password);
ここでホストは、openfire が設定されている IP/ドメイン名です。
これはサンプルであり、gtalkでステータスメッセージを設定するのに役立ちます。
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Presence;
public class SmackToGtalk {
public static void main(String[] args)
{
ConnectionConfiguration config = new ConnectionConfiguration(
"talk.google.com", 5222, "google.com");
XMPPConnection connection = new XMPPConnection(config);
Presence presence;
String status;
try {
connection.connect();
connection.login("mail_id@gmail.com", "password");
status = "DND";
presence = new Presence(Presence.Type.available, status, 24,
Presence.Mode.available);
while (true) {
status = set(status);
presence.setStatus(status);
connection.sendPacket(presence);
Thread.sleep(1000);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
connection.disconnect();
}
}
private static String set(String input) {
return input.substring(1) + input.charAt(0);
}
}
openfire と一緒に smack API を使用することにしました..しかし、openfire サーバーでそれを使用する方法については、ほとんどガイダンスが必要ありません..
Smack API Getting Startedはどうですか?
また、openfire は、ログイン ボックスのチャット ウィンドウなどの基本的な UI を提供しますか?
OpenFire は単なるサーバーです。実際にチャットするには、Jabber/XMPP クライアントが必要です。テストにはSparkを使用できます。
JSP / Java で、smack.jar をインポートします。
<%@ page import="org.jivesoftware.smack.*;" %>
smack.jar を配置します
tomcat/lib
または yourwebapp/WEB-INF/lib