Not logged in. · Lost password · Register
Forum: agsXMPP RSS
repost for last wrong display
Avatar
mentor #1
Member since Mar 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: MUC room can't setup?
In my program, I first login to Wildfire server,  and then try to set up a MUC room and invite a user to join.
The login succeeded, but there is no reponse for room setup. In fact, the call back function to process received data from server seem not run, and there is no logged info.

Would you kindly like to have look at the program for me?

public class testMUC
{
    pulic testMUC()
    {
    } 

    public void setupRoom()
    {  
      /// prepare data for callback method
        chResponse myResponse = new chResponse();
        myResponse.userJid = new agsXMPP.Jid( "username@81939b411fc8453");
        myResponse.roomJID = new agsXMPP.Jid(roomName + "@81939b411fc8453/myroom");
    mychatResponse.status = "ROOM_SETTINGUP";

      /// Setup connection
        agsXMPP.XmppClientConnection jabberconn = new agsXMPP.XmppClientConnection("81939b411fc8453");
        jabberconn.Open("admin", "******");

      /// Setup Room
        agsXMPP.protocol.client.Presence MUCpresence = new agsXMPP.protocol.client.Presence();
        MUCpresence.From = "admin@81939b411fc8453/manager";
        MUCpresence.To   = myResponse.roomJID
        MUCpresence.MucUser = new agsXMPP.protocol.x.muc.User();

        jabberconn.Send(MUCpresence);

      /// Prepare Presence callback
        agsXMPP.PresenceCB<chResponse> preshandler = new agsXMPP.PresenceCB<chResponse>(HandlePresence);
        jabberconn.m_PresenceGrabber.Add<chResponse>(roomJID, preshandler, myResponse);

      /// check reuslt   
    while(myResponse.status ="ROOM_SETTINGUP")
        {
           Thread.Sleep(new System.TimeSpan(50000));
    }
        return;
    }

    private static void HandlePresence(object sender, agsXMPP.protocol.client.Presence pres, chResponse myResponse)
    {
        dbg("start processing presence ...");
 
        if (pres.From == myResponse.roomJID && pres.HasTag("status", true))
        {
            if (pres.SelectSingleElement("status", true).GetAttribute("code") == "201")
            {
            myResponse.status = "ROOM_SETTUP";

           /// Room setup, then Invite a user
                string reason = "";
                agsXMPP.protocol.x.muc.MucManager myMucManager = new agsXMPP.protocol.x.muc.MucManager(jabberconn);
                myMucManager.Invite(myResponse.userJid, myResponse.roomJID, reason);

               /// prepare callback method
                agsXMPP.MessageCB<chResponse> msgHandler = new agsXMPP.MessageCB<chResponse>(HandleMessage);
                jabberconn.m_MessageGrabber.Add<chResponse>(myResponse.roomJID, msgHandler, myResponse);               
            }
            else
            {
                mychatResponse.status = "ROOM_SETUP_FAILED"; 
            }
        }
    }

    private static void HandleMessage(object sender, agsXMPP.protocol.client.Message Msg, chResponse myResponse)
    {
        dbg("start processing mucMessage ...");

        if (Msg.From == myResponse.roomJID && (Msg.HasTag("Decline")))
            myResponse.status = "INVITATION_DECLINED";            
    else
        myResponse.status = "INVITATION_ACCEPTED";
    }

}

/// Data Structure
public class chatResponse
{
    public chatResponse()
    {
    }

    private agsXMPP.Jid  m_roomJID;
    private agsXMPP.Jid  m_userJid;
    private string     m_status;

    public agsXMPP.Jid userJid
    {
        get { return m_userJid; }
        set { m_userJid = value; }
    }
    public agsXMPP.Jid roomJID
    {
        get { return m_roomJID; }
        set { m_roomJID = value; }
    }
    public string status
    {
        get { return m_status; }
        set { m_status = value; }
}

I checked the packet sent out to server is as

{<presence xmlns="jabber:client" from="amin@81939b411fc8453/manager" to="v6bwuCvizG@81939b411fc8453/myroom"><x

xmlns="http://jabber.org/protocol/muc#user" /></presence>}

I wonder

 1) is there any agsXMPP lib function wrongly used?
 2) How could I step into the call back function to see whether it's running, besides just printing some data in the function?

Thanks for your attention.

The version of Wildfire is 3.2.2, and agsXMPP is downloaded here recently.
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The Open method is asynchronous. This means when it returns you app is connecting, but it's not connected.
Use the search function and you will find many threads with the same problem.

Alex
Avatar
mentor #3
Member since Mar 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
Sorry, I searched the forum to find the way to use JoinRoom() method. So I changed the test function as following, but it still failed as before. When I trace in JoinRomm(), I found the presence packet has no From Attribute, Would it work without this attribute, or somewhere it's added automatically ?


 public void setupRoom()
    {  
      /// prepare data for callback method
        chResponse myResponse = new chResponse();
        myResponse.userJid = new agsXMPP.Jid( "username@81939b411fc8453");
        myResponse.roomJID = new agsXMPP.Jid(roomName + "@81939b411fc8453");
    mychatResponse.status = "ROOM_SETTINGUP";

      /// Setup connection
        agsXMPP.XmppClientConnection jabberconn = new agsXMPP.XmppClientConnection("81939b411fc8453");
        jabberconn.Open("admin", "******");

      /// Prepare Presence callback
        agsXMPP.PresenceCB<chResponse> preshandler = new agsXMPP.PresenceCB<chResponse>(HandlePresence);
        jabberconn.m_PresenceGrabber.Add<chResponse>(roomJID, preshandler, myResponse);

            agsXMPP.protocol.x.muc.MucManager man = new agsXMPP.protocol.x.muc.MucManager(jabberconn);
            man.JoinRoom(roomJID, "myroom");


      /// check reuslt   
    while(myResponse.status ="ROOM_SETTINGUP")
        {
           Thread.Sleep(new System.TimeSpan(50000));
    }
        return;
    }

The room still not setup.
Avatar
mentor #4
Member since Mar 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
In fact, before setup room, I checked the connection in my real program, those in last post is simplified. the checking is as below,

        do // if connected, can't reconnect ?
        {
            Thread.Sleep(new System.TimeSpan((System.Int64)10000 * 5));
        } while (jabberconn.ConnectionState != agsXMPP.XmppConnectionState.Connected && (jabberconn.ConnectionState != agsXMPP.XmppConnectionState.Error));

After this I try to setup room. So the connection should has been connected I think.
Avatar
Alex #5
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by mentor:
<presence xmlns="jabber:client" from="amin@81939b411fc8453/manager" to="v6bwuCvizG@81939b411fc8453/myroom"><x xmlns="http://jabber.org/protocol/muc#user" /></presence>

The to Jid in your log looks wrong and not like a chatroom Jid.
Please look i nthe MiniClient example how you build the Jids in chatrooms.
There is a complete Muc example in the MiniClient.
Take also a look at this thread: http://forum.ag-software.de/forum.php?req=thread&id=335

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS