Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Preventing errors on Server
Avatar
zackrspv #1
Member since Sep 2010 · 29 posts
Group memberships: Members
Show profile · Link to this post
Subject: [RESOLVED] Custom Packets
Alex:

I followed the walk-through on how to create my own custom packets in XMPP.  It works quite well, and fits my needs, however, while the tags returned in IQ are still parseable, the server still responds with error 400 -- bad request:

Command Button Clicked for User:  Checking Idle time for user:  Phillip XXXXXX
Will Send:  <message xmlns="jabber:client" to="ROOM@server.namespace"><chkidle xmlns="testcs:chkidle"><whoSent>Phillip XXXXXX</whoSent><whoQuery>Phillip XXXXXX</whoQuery></chkidle></message>

Command received in room:  ROOM@server.namespace

<message xmlns="jabber:client" to="pxxxxxx@server/testcs" type="error" from="ROOM@server.namespace"><chkidle xmlns="testcs:chkidle"><whoSent>Phillip XXXXXX</whoSent><whoQuery>Phillip XXXXXX</whoQuery></chkidle><error type="modify" code="400"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></message>
Command Parsed, had tag of ChkIdle:  User:  Phillip XXXXXX queried user:  Phillip XXXXXX.  We will be responding with:  0 seconds.
Will Send:  <message xmlns="jabber:client" to="ROOM@server.namespace"><respondidle xmlns="testcs:respondidle"><whoSent>Phillip XXXXXX</whoSent><whoQuery>Phillip XXXXXX</whoQuery><idleTime>0 seconds.</idleTime></respondidle></message>

Command received in room:  ROOM@server.namespace

<message xmlns="jabber:client" to="pxxxxxx@server/testcs" type="error" from="ROOM@server.namespace"><respondidle xmlns="testcs:respondidle"><whoSent>Phillip XXXXXX</whoSent><whoQuery>Phillip XXXXXX</whoQuery><idleTime>0 seconds.</idleTime></respondidle><error type="modify" code="400"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></message>
Command Parsed, had tag of RespondIdle:  User:  Phillip XXXXXX responded to user:  Phillip XXXXXX with:  0 seconds.


So, as you can see, it does indeed respond to each of the custom packets (ChkIdle) and (RespondIdle), however the server errors on them.

I DO NOT wish to fill up the server with lots of errors, so do i need to configure the server for something?
This post was edited on 2011-06-23, 01:44 by zackrspv.
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
it look to me like the to Jid is wrong. You send the message to ROOM@server.namespace. Is your xmpp domain server.namespace?

Alex
Avatar
zackrspv #3
Member since Sep 2010 · 29 posts
Group memberships: Members
Show profile · Link to this post
I think i may have screwed that up when sanitizing it here for a web post ha.


Responding to user action (clicked on ‘Check Idle’ in UI)
Checking Idle time for user:  Phillip XXXXXX

Will Send:  <message xmlns="jabber:client" to="ROOM@CONFERENCESERVICE.SERVER"><chkidle xmlns="testcs:chkidle"><whoSent>Phillip XXXXXX</whoSent><whoQuery>Phillip XXXXXX</whoQuery></chkidle></message>

ROOM@CONFERENCESERVICE.SERVER RESPONDED with: 

<message xmlns="jabber:client" to="pXXXXXX@SERVER/testcs" type="error" from="ROOM@CONFERENCESERVICE.SERVER"><chkidle xmlns="testcs:chkidle"><whoSent>Phillip XXXXXX</whoSent><whoQuery>Phillip XXXXXX</whoQuery></chkidle><error type="modify" code="400"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></message>
-----------------------------------------------------------------------------------
IQ tags found for chkIdle, processing:
User:  Phillip XXXXXX queried user:  Phillip XXXXXX.  We will be responding with:  0 seconds.

Will Send:  <message xmlns="jabber:client" to="ROOM@CONFERENCESERVICE.SERVER"><respondidle xmlns="testcs:respondidle"><whoSent>Phillip XXXXXX</whoSent><whoQuery>Phillip XXXXXX</whoQuery><idleTime>0 seconds.</idleTime></respondidle></message>

ROOM@CONFERENCESERVICE.SERVER RESPONDED with: 

<message xmlns="jabber:client" to="pXXXXXX@SERVER/testcs" type="error" from="ROOM@CONFERENCESERVICE.SERVER"><respondidle xmlns="testcs:respondidle"><whoSent>Phillip XXXXXX</whoSent><whoQuery>Phillip XXXXXX</whoQuery><idleTime>0 seconds.</idleTime></respondidle><error type="modify" code="400"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></message>
-----------------------------------------------------------------------------------
IQ tags found for respondIdle, processing:
User:  Phillip XXXXXX responded to user:  Phillip XXXXXX with:  0 seconds.
Avatar
Alex #4
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
when you are sending this messages to a conferencing service then try to set the message type to groupchat.

Alex
Avatar
zackrspv #5
Member since Sep 2010 · 29 posts
Group memberships: Members
Show profile · Link to this post
I must have totally screwed something up here, now the messages are not even parsing:

The Check Idle Class, has 2 classes, one to query and one to respond.

using agsXMPP.Xml.Dom;

namespace Tasukete2
{
    public class ChkIdle : Element
    {
        private ChkIdle()
        {
            TagName = "chkidle";
            Namespace = "testcs:chkidle";
        }

        public ChkIdle(string whoSent, string whoQuery) : this()
        {
            WhoSent = whoSent;
            WhoQuery = whoQuery;
        }

        public string WhoSent
        {
            get { return GetTag("whoSent"); }
            private set { SetTag("whoSent", value);}
        }

        public string WhoQuery
        {
            get { return GetTag("whoQuery"); }
            private set { SetTag("whoQuery", value); }
        }
    }

    public class RespondIdle : Element
    {
        private RespondIdle()
        {
            TagName = "respondidle";
            Namespace = "testcs:respondidle";
        }

        public RespondIdle(string whoSent, string whoQuery, string idleTime)
            : this()
        {
            WhoSent = whoSent;
            WhoQuery = whoQuery;
            IdleTime = idleTime;
        }

        public string WhoSent
        {
            get { return GetTag("whoSent"); }
            private set { SetTag("whoSent", value);}
        }

        public string WhoQuery
        {
            get { return GetTag("whoQuery"); }
            private set { SetTag("whoQuery", value); }
        }

        public string IdleTime
        {
            get { return GetTag("idleTime"); }
            private set { SetTag("idleTime", value); }
        }

    }
}



The commands (triggers when a user right clicks on a user name inside of the roster and selects 'Check Idle Time':

var node = _rosterControl1.SelectedItem();
if (node != null)
{
                    var nick = node.Text.Replace("'", string.Empty);
                    var chkIdle = new ChkIdle(_txtFullname, nick);
                    Jid to = _room2Jid;
                    var msg = new Message { To = to, Type = MessageType.groupchat };
                    // Add our weather Element
                    msg.AddChild(chkIdle);
                    // Send the message
                    _xmpp.Send(msg);
}

And on the OnMessage():

if (msg.HasTag(typeof(ChkIdle)))
            {
                var chkIdle = msg.SelectSingleElement(typeof(ChkIdle)) as ChkIdle;
                if (chkIdle != null)
                {
                    Console.WriteLine(chkIdle.WhoSent);
                    Console.WriteLine(chkIdle.WhoQuery);
                }
            }

The problem?  I can see it send the message:

<message xmlns="jabber:client" to="pxxxxxx@SERVER/testcs" type="groupchat" from="ROOM@CONFERENCESERVICE.SERVER/Phillip XXXX"><chkidle xmlns="testcs:chkidle"><whoSent>Phillip XXXXXX</whoSent><whoQuery>Phillip XXXXXX</whoQuery></chkidle></message>

So, will groupchat messages not respond to the Has Tag?  Because it doesn't catch it in the OnMessage().
Avatar
zackrspv #6
Member since Sep 2010 · 29 posts
Group memberships: Members
Show profile · Link to this post
i think i may just give up *sighs*.

I added:  agsXMPP.Factory.ElementFactory.AddElementType("chkidle", "testcs:chkidle", typeof(ChkIdle));

To the top of the Form Constructor, so that it'd register that.

And now, i'm having an error *sighs*.

This is just so frustrating :(

No parameterless constructor defined for this object.

gah!  It happens the INSTANT i send the message to the server.
Avatar
zackrspv #7
Member since Sep 2010 · 29 posts
Group memberships: Members
Show profile · Link to this post
I figured out the error i had above at least, for some reason my class had the constructor set to 'private'.  I set to public and the parameterless error is gone.  I think i just need to take a break *sighs*
Avatar
Alex #8
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
There must be always a public constructor without parameters, because the library creates the classes with reflection using this constructor in the Xml parser.

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