Not logged in. · Lost password · Register
Forum: agsXMPP RSS
custom packets
Page: previous  1  2 
Avatar
blorecrafter #16
Member since Aug 2008 · 3 posts
Group memberships: Members
Show profile · Link to this post
In reply to post ID 3426
Hi Alex
Thanks for the info. i will try doing it that way...
blorecrafter
Avatar
designbert #17
Member since Dec 2008 · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: registering custom extension namespace
Hello!

I am fairly green. I have gotten the example code here which i bolted onto the Gtalk sample to send the weather xml data:


msg = {<message xmlns="jabber:client" to="admin@development-box"><weather xmlns="agsoftware:weather"><humidity>75</humidity><temperature>63</temperature></weather></message>}

 However, I do not think I have registered the extension properly  because when my client recieves the xml, it dosent seem to find it as type 'weather'. it seems to just skip over it. im not sure what code to paste..

 Do I need to have more references than just the agsXMPP.dll? Such as to the full agsXMPP2008 project? I am editing the URI.cs and element factory.cs files in an open instance of the agsxmp2008 project, but I am not referencing it in my gtalk example which i have opened separately.

If i cannot get it after some more struggling, i will zip files and make a more formal appeal for help.

Using the first example code, without the tagname changed to query, I get this error:

(added into elementfactory.cs)
 AddElementType("weather", Uri.WEATHER, typeof(agsXMPP.protocol.extensions.Weather.Weather));


(added into Uri.cs)
        //Weather Extension

        public const string WEATHER = "agsoftware:weather";


Error    5    The type or namespace name 'Weather' does not exist in the namespace 'agsXMPP.protocol.extensions' (are you missing an assembly reference?)    C:\Program Files\AG-Software\agsXMPP SDK\agsxmpp\Factory\ElementFactory.cs    305    85    agsXMPP2008

thanks you.

Robert
This post was edited on 2008-12-23, 06:16 by designbert.
Avatar
Alex #18
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
If you put this lines in the agsXMPP code you of course have to recompile it and reference the new recompiled agsXMPP.dll in the Gtalk project.
You can put the weather classes directly in the Gtalk project and register it from there in the ElementFactory.

Alex
Avatar
wenliang1234567 #19
User title: sun
Member since Mar 2010 · 2 posts · Location: china
Group memberships: Members
Show profile · Link to this post
Subject: Hi,Alex
Hi,Alex,I run example i,and can't receive weather message.

private void XmppCon_OnMessage(object sender, Message msg)
{
    if (msg.HasTag(typeof(Weather)))     {
         Weather weather = msg.SelectSingleElement(typeof(Weather)) as Weather;
         Console.WriteLine(weather.Temperature.ToString());
         Console.WriteLine(weather.Humidity.ToString());
     }
}

I have register element with "agsXMPP.Factory.ElementFactory.AddElementType("weather",
"agsoftware:weather", typeof(Weather))" in form_load of my project.
In the onXMLRead event,I can receive the XML data,"<message xmlns="agsoftware:weather"><from="sun@10.52.81.225/agsXMPP" to="037896@10.52.81.225"><Weather><humidity>90</humidity><temperature>57</temperature></Weather></message>",
the red with red color can't run.

Thanks!
Avatar
Alex #20
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
your Xml looks totally wrong. Can you please post or attach your complete code?

Alex
Avatar
wenliang1234567 #21
User title: sun
Member since Mar 2010 · 2 posts · Location: china
Group memberships: Members
Show profile · Link to this post
Subject: Anthoer problem.
Thanks Alex.
I have found the reason about my previous question.But I found anther problem.I run example one(Weather),when another people is offline,I send messge to her,the table ofoffline doesn't save message.So when another people login,she can't receive my sent message,how can I do?
I am sorry,my English is poor,Thanks again!
Avatar
Alex #22
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
If a user is oflfine and you send the message to a full Jid the server returns it with an error. The same applies to servers or user accounts which support no offline storage

  • When a user is offline then you must send the message to the bare jid.
  • check for response messages of type error to see if you sent a message to a resource which is not available anymore f id the server of the user supports no offline storage.

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:
Page: previous  1  2 
Forum: agsXMPP RSS