<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>MUC and creating rooms</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2 FACE="Arial">All,</FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial">I'm sure I'm doing something wrong, but I've been banging up against the most frustrating problem having a bot create a chat room, and I've found some unusual behavior by looking at debugging output from the Exodus client. To begin with, I know that MUC is properly installed on my server because I can create conference rooms on the fly using Exodus.</FONT></P>
<P> <FONT SIZE=2 FACE="Arial">I've been using the Net::Jabber Perl library to have a bot connect using MUCJoin (I have v1.28). The following is an outline of my code:</FONT></P>
<P> <FONT SIZE=2 FACE="Arial">$jabber = new Net::Jabber::Client();</FONT>
<BR> <FONT SIZE=2 FACE="Arial"> my ($status) = $jabber->Connect(hostname=>$j_server, port=>$j_port);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">my (@result) = $jabber->AuthSend(username=>$user, password=>$pass, resource=>$resource);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">$jabber->MUCJoin(room=>$room_name, server=>$j_chat_server, nick=>$chat_nickname);</FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial">If I look in the ".../jabber/spool/<chat server name>/" directory I don't see any files created, and I can't get another client to connect to that room (keep getting a "Forbidden" message in Exodus). Frustratingly, I have to restart the Jabber server before I can try to create this room with Exodus, which is annoying but not necessary for my project. I assume this is because the room is in some half-created state and the server is not allowing anyone else to create a room with the same name.</FONT></P>
<P> <FONT SIZE=2 FACE="Arial">So I looked at the debug output from the Exodus connection/creation of the conference room and found that if I do what it does everything works fine. This amounts to the following, which as you can see is ugly and undesirable:</FONT></P>
<P><FONT SIZE=2 FACE="Arial"> $jabber = new Net::Jabber::Client();</FONT>
<BR> <FONT SIZE=2 FACE="Arial"> my ($status) = $jabber->Connect(hostname=>$j_server, port=>$j_port);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">my (@result) = $jabber->AuthSend(username=>$user, password=>$pass, resource=>$resource);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">$jabber->MUCJoin(room=>$room_name, server=>$j_chat_server, nick=>$chat_nickname);</FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial"> # this is the first part of the hack protocol, which will send back a config "form",</FONT>
<BR><FONT SIZE=2 FACE="Arial"> # which describes the room's settings</FONT>
<BR><FONT SIZE=2 FACE="Arial"> my ($iq) = new Net::Jabber::IQ();</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $iq->SetIQ(to=>$room_name.'@'.$j_chat_server, type=>"get");</FONT>
<BR><FONT SIZE=2 FACE="Arial"> my ($iq_type) = $iq->NewQuery();</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $iq_type->SetXMLNS("<A HREF="http://jabber.org/protocol/muc#owner" TARGET="_blank">http://jabber.org/protocol/muc#owner</A>");</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $jabber->Send($iq, 1);</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> # this is the second part of the hack that just accepts the default settings</FONT>
<BR><FONT SIZE=2 FACE="Arial">my ($msg) =<<EOL;</FONT>
<BR><FONT SIZE=2 FACE="Arial"><iq to="$room_name\@$j_chat_server" type="set"><query xmlns="<A HREF="http://jabber.org/protocol/muc#owner" TARGET="_blank">http://jabber.org/protocol/muc#owner</A>"><x type="submit" xmlns="jabber:x:data"><title>Room configuration</title><field var="logformat"><value>text</value></field><field var="logging"><value>0</value></field><field var="whois"><value>admins</value></field><field var="password"><value>0</value></field><field var="invites"><value>0</value></field><field var="invitation"><value>0</value></field><field var="privmsg"><value>0</value></field><field var="defaulttype"><value>0</value></field><field var="moderated"><value>0</value></field><field var="legacy"><value>1</value></field><field var="persistant"><value>0</value></field><field var="public"><value>1</value></field><field var="privacy"><value>1</value></field><field var="participants"><value>30</value></field><field var="subject"><value>0</value></field><field var="rename"><value>is now known as</value></field><field var="join"><value>has become available</value></field><field var="leave"><value>has left</value></field><field var="title"><value>t1</value></field><field var="form"><value>config</value></field></x></query></iq></FONT></P>
<P><FONT SIZE=2 FACE="Arial">EOL</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> $jabber->Send($msg);</FONT>
</P>
<BR>
<P> <FONT SIZE=2 FACE="Arial">Now, this creates the room (by which I mean I see a file in ".../jabber/spool/<chat server name>/") which other clients can connect to. There are a couple of things I don't understand:</FONT></P>
<P> <FONT SIZE=2 FACE="Arial">1) If I send any less than the complete registration form ("$msg" above) it doesn't work</FONT>
<BR> <FONT SIZE=2 FACE="Arial">2) Why do I have to take those extra steps at all? Shouldn't MUCJoin take care of all this for me? Does this imply a problem or is this expected behavior?</FONT></P>
<P> <FONT SIZE=2 FACE="Arial">I've seen some unrelated posts about joining a MUC so my apologies if this is a known problem that I wasn't able to find.</FONT></P>
<P> <FONT SIZE=2 FACE="Arial">-Vinny</FONT>
</P>
<BR>
</BODY>
</HTML>