API QUICKBLOX に問題があります。"MUC" を入力すると、奇妙なエラーが発生します。理由がわかりません。
public class MyChatController {
// ================= QuickBlox ===== Step 8 =================
// Get QuickBlox chat server domain.
// There will be created connection with chat server below.
public static final String CHAT_SERVER = QBChat.getChatServerDomain();
private XMPPConnection connection;
private ConnectionConfiguration config;
private Chat chat;
// Multi-User Chat, también conocido como
// MUC, es un robusto protocolo de conferencia basado en XMP.
// Fue desarrollado como un sistema de chat en grupo para extender
// la funcionalidad de clientes Jabber/XMPP, cuyo protocolo sólo permite
// establecer conferencias entre 2 personas. Ha sido acogido como propuesta
// de extensión XEP-0045, y se ha incluido de forma nativa en el programa servidor ejabberd.
private MultiUserChat muc2;
private String chatLogin;
private String password;
private String friendLogin;
private ChatManager chatManager;
public MyChatController(String chatLogin, String password) {
this.chatLogin = chatLogin;
this.password = password;
}
public void startChat(String buddyLogin) {
this.friendLogin = buddyLogin;
new Thread(new Runnable() {
@Override
public void run() {
// Chat action 1 -- create connection.
Connection.DEBUG_ENABLED = true;
config = new ConnectionConfiguration(CHAT_SERVER);
connection = new XMPPConnection(config);
try {
connection.connect();
connection.login(chatLogin, password);
// Chat action 2 -- create chat manager.
chatManager = connection.getChatManager();
// Chat action 3 -- create chat.
chat = chatManager.createChat(friendLogin, messageListener);
// Set listener for outcoming messages.
chatManager.addChatListener(chatManagerListener);
// Muc 2
muc2 = new MultiUserChat(connection, "2387_chat1@muc.chat.quickblox.com");
// Discover whether user3@host.org supports MUC or not
// The room service will decide the amount of history to send
muc2.join(chatLogin);
muc2.invite(friendLogin, "Welcome!");
Log.d("friendLogin ->",friendLogin);
// Set listener for outcoming messages.
//chatManager.addChatListener(chatManagerListener);
muc2.addMessageListener(packetListener);
addListenerToMuc(muc2);
//chat1@muc.chat.quickblox.com --- el meu
Message message = new Message(friendLogin + "@muc.chat.quickblox.com");
message.setBody("Join me for a group chat!");
message.addExtension(new GroupChatInvitation("2387_chat1@muc.chat.quickblox.com"));
connection.sendPacket(message);
} catch (XMPPException e) {
e.printStackTrace();
}
}
}).start();
}
/*** muc */
private void addListenerToMuc(MultiUserChat muc){
if(null != muc){
muc.addMessageListener(new PacketListener() {
@Override
public void processPacket(Packet packet) {
Log.i("processPacket", "receiving message");
}
});
}
}
PacketListener packetListener = new PacketListener() {
@Override
public void processPacket(Packet packet) {
Message message = (Message)packet;
try {
muc2.sendMessage(message);
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println("got message " + message.toXML());
}
};
private PacketInterceptor packetInterceptor = new PacketInterceptor() {
@Override
public void interceptPacket(Packet packet) {
System.out.println("Sending message: " + packet.toString());
Message message = muc2.createMessage();
message.setBody("Hello from producer, message " +
" ");
try {
muc2.sendMessage(message);
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
/***/
エラー:
05-20 23:16:19.679: E/AndroidRuntime(3361): FATAL EXCEPTION: Thread-277
05-20 23:16:19.679: E/AndroidRuntime(3361): java.lang.NullPointerException
05-20 23:16:19.679: E/AndroidRuntime(3361): at org.jivesoftware.smackx.muc.MultiUserChat$1.connectionCreated(MultiUserChat.java:114)
05-20 23:16:19.679: E/AndroidRuntime(3361): at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:607)
05-20 23:16:19.679: E/AndroidRuntime(3361): at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:556)
05-20 23:16:19.679: E/AndroidRuntime(3361): at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:984)
05-20 23:16:19.679: E/AndroidRuntime(3361): at com.quickblox.sample.chat.MyChatController$5.run(MyChatController.java:73)
05-20 23:16:19.679: E/AndroidRuntime(3361): at java.lang.Thread.run(Thread.java:856)
05-20 23:16:19.807: E/Trace(3445): error opening trace file: No such file or directory (2)