i want to use smack but i have no idea that what facilities are smack give in application.
i want to know specially about white board and conference support in instance messenger.
can u guide me , please?
i want to use smack but i have no idea that what facilities are smack give in application.
i want to know specially about white board and conference support in instance messenger.
can u guide me , please?
Hi, iampathik:
I am also trying for these aspects such as MUC and Conference. In my working, I failed to try to creat a MUC,here is my source code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.log4j.Logger;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.Form;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Message;
public class TestMUC extends Thread{
static Logger logger = Logger.getLogger(TestMUC.class.getName());
XMPPConnection con;
MultiUserChat muc;
boolean live = true;
public TestMUC() {
}
public void login() {
try {
con = new XMPPConnection(“localhost”);
con.login(“dabao”, “mypass”);
logger.info(“Dabao login successfully”);
}catch(Exception ex) {
ex.printStackTrace();
}
}
public void createMUC() {
try {
muc = new MultiUserChat(con, “myroom@conference.localhost”);
muc.create(“testbot”);
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
addMessageListener();
logger.info(“MUC created”);
}catch(Exception ex) {
ex.printStackTrace();
}
}
public void inviteFriend(String jid) {
if(muc == null) {
logger.info(“ERROR:muc is null.”);
return;
}
muc.invite(jid, “come on”);
}
public void addMessageListener() {
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
logger.info(“receive a packet.”);
logger.info(“packet type:” + packet.getClass().getName());
if(packet instanceof Message) {
Message msg = (Message)packet;
String jid = msg.getFrom();
String body = msg.getBody();
logger.info(jid + “:” + body);
}
}
};
if(muc != null) {
muc.addMessageListener(packetListener);
}
}
public void run() {
while(live){
try {
messageConsole();
}catch(Exception ex) {
ex.printStackTrace();
}
}
}
public void messageConsole() {
logger.info(“please input chat messages:”);
BufferedReader reader = new BufferedReader(
new InputStreamReader(System.in));
try {
String line = reader.readLine();
line = line.trim();
while (!line.equals(“exit”)) {
logger.info(“send:” + line);
muc.sendMessage(line);
line = reader.readLine();
}
logger.info(“done.”);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void die() {
live = false;
}
public void finalize() {
die();
}
/**
*/
public static void main(String[] args) {
TestMUC tmuc = new TestMUC();
tmuc.login();
tmuc.createMUC();
tmuc.inviteFriend(“baal@localhost”);
tmuc.start();
}
}
/code
do you mean this?
Smack does not have support for whiteboards (yet) but it does support MultiUserChat. You can read url=http://www.jivesoftware.org/builds/smack/docs/latest/documentation/extension s/muc.htmlthis documentation[/url] about MUC.
Regards,
– Gato
Gato, your link is getting me to a “Page Not Found”. Thats because of a space in the end of URL. Have to delete %20 in m%20uc.html
These problems are very often in Jive Forum. Can something be done?