Hello… I’'m newbie in spark dev…
now, i’‘m trying to make a plugin on Spark. My plugin is a button on ChatRoom and my scenario is when my button clicked, it send a message to my partner that i chat with. i success to make a button on the chatroom but i failed to send a message to my partner when the button is clicked. I’‘m looking this topic on the forum but i can’'t found one…
I’‘m trying to using method sendMessage on Chat class but i didn’'t know how to get my partner JID. Even it make spark fail to load. so anybody can help me how to solve this problem???
thnx for ur attention…
Hi gbe_big,
Below is a snippet of code that shows how to add a button to the chat room (which I know you’‘ve already done) and how to get the JID of the person you’'re chatting with:
private void addChatRoomEditorButton() {
ChatManager chatManager = SparkManager.getChatManager(); final ChatRoomButton button = new ChatRoomButton(getImageIcon("stock_copy.png"));
button.setToolTipText("Share an editor"); chatManager.addChatRoomListener(new ChatRoomListenerAdapter() {
public void chatRoomOpened(final ChatRoom room) {
room.getToolBar().addChatRoomButton(button);
button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {
String pJID = ((ChatRoomImpl) room).getParticipantJID();
//there you have it :)
}});
} public void chatRoomLeft(ChatRoom room) {
room.getToolBar().removeChatRoomButton(button);
}
});
}
Hope that helps,
Ryan