Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
earn #1
Member since Feb 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Simple message send
Hi.
I know the question is silly, but i newbie with VB.NET and protocols.
I'm trying to create the class that would send a message to some users, nothing more. It would be a part of other application.
I wanted to use the 3-line example to do it, but somehing is missing and I don't know what it is.

// Wait for the OnLogin event and send your message   <--what is this OnLogin event.

I tried the MiniClient and it worked fine, i could see other users, send and receive messages.

When I used the 3-line sample as it is nothing hapenned, and the server registerd an attempt of connection, nothing more.
Please help me to solve this silly problem.

E
Avatar
earn #2
Member since Feb 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
Line : xmpp.Send( new  Message("myuser@myserver", MessageType.chat, "Hello, how are you?"));
causes the "Object reference not set to an instace of an object" exception.
Please give me any hints, what could cause this problem.
E
Avatar
Alex #3
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

the library is using all asynchronous communications. This is also why there is the comment to with the OnLogin event.
You can't send the a message before you are authenticated and logged in.
Subscribe to the OnLogin handler and execute the 3rd line in the the small example after the OnLogin event occured.

Alex
Alexander Gnauck
AG-Software
Avatar
earn #4
Member since Feb 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,
Thank you for your reply, this is my code.
Before sending a message I check the boolean value, but it's not working well, because I still get the exception I wrote before.
Please tell me what I'm doing wrong.
Thank you for your help.
E

Imports agsXMPP
Imports agsXMPP.protocol.client

Public Class XMPPMsg
    Private WithEvents XmppCon As XmppClientConnection
   
    Dim msg As agsXMPP.protocol.client.Message = New agsXMPP.protocol.client.Message
    Dim connTest as Boolean =false
   
     Private Sub XmppCon_OnLogin(ByVal sender As Object) Handles XmppCon.OnLogin
   
        XmppCon.SendMyPresence()   
        connTest=true
      End Sub
     
    Public Sub SendXMPPMsg()
       
        Dim xmppcon As XmppClientConnection = New XmppClientConnection ("rmyServer")
        Dim Jid As agsXMPP.Jid= New agsXMPP.Jid("user@myServer")
       
        msg.Type = MessageType.chat
        msg.To = Jid
        msg.Body = "Test"
        xmppcon.Open("myUser", "myPass")
       
            If connTest=true then
             Try
                xmppCon.Send(msg)
                Catch ex As exception
                msgbox(ex.Message)
            Finally
                Xmppcon.close()
            End Try       
        end if
    End Sub   
End Class
Avatar
Alex #5
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi,

this will not work. As i said before the Open method is asynchronous and returns immediately. You have to block your code after the Open call until you get the OnLogin event. You can do that eg with Monitors from System.Threading.
Or send you message in the OnLogin event.

Alex
Alexander Gnauck
AG-Software
Avatar
earn #6
Member since Feb 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,
huge thanks for your help!

I tried the secound solution, this is sending the message in the OnLogin event, but it's still not working as the OnLogin Event is never fired and I don't know why. This the changed code:

Imports agsXMPP
Imports agsXMPP.protocol
Imports agsXMPP.protocol.client

Public Class XMPPMsg
        
    Public WithEvents XmppCon As XmppClientConnection
      Public Sub SendXMPPMsg()
               
        xmppcon=New XmppClientConnection("myServer")
        XmppCon.Open("myUser@myserver", "myPass")
           
    End Sub

 Public Sub XmppCon_OnLogin(ByVal sender As Object) Handles XmppCon.OnLogin
                   Try
                xmppCon.Send(new  Message("user@server", MessageType.chat, "Hello, how are you?"))
            Catch ex As exception
                msgbox(ex.Message)
            End Try
 End Sub
End Class

Could it be an authentification problem? I use the same user and pass as in the MiniClient Sample which works perfectly.
Thank you again.
E
Avatar
Alex #7
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

Please post your debug XML which you get from the handlers OnReadXML and OnWriteXml.
Are you using .NET 1.1 or 2.0?

Alex
Alexander Gnauck
AG-Software
Avatar
earn #8
Member since Feb 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,
Thank you for your quick response.

I'm using .NET 1.1.

This's the XML

SEND: <stream:stream to='roracle' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
RECV: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="roracle" xml:lang="en" id="2c8383ad" >
SEND: <iq xmlns="jabber:client" id="agsXMPP_1" type="get" to="roracle"><query xmlns="jabber:iq:auth"><username>karol@roracle</username></query></iq>
RECV: <iq xmlns="jabber:client" from="roracle" id="agsXMPP_1" type="result"><query xmlns="jabber:iq:auth"><username>karol@roracle</username><password /><digest /><resource /></query></iq>
SEND: <iq xmlns="jabber:client" id="agsXMPP_2" to="roracle" type="set"><query xmlns="jabber:iq:auth"><username>karol@roracle</username><digest>3f961a19da454c232c59601348e525a1c2b316fc</digest><resource>agsXMPP</resource></query></iq>
RECV: <iq xmlns="jabber:client" from="roracle" id="agsXMPP_2" to="roracle/2c8383ad" type="error"><query xmlns="jabber:iq:auth"><username>karol@roracle</username><digest>3f961a19da454c232c59601348e525a1c2b316fc</digest><resource>agsXMPP</resource></query><error code="401" type="auth"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>


E
Avatar
Jabberer #9
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
in your logs the username is karol@roracle.
The username must be karol only.

  • karol@roracle is your Jabber ID
  • karol is your username
  • roracle is your XMPP domain
Software Developer
AG-Software
Avatar
earn #10
Member since Feb 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
:) what a mistake
You are the best guys!!!
Thanks a million for all your help.

E
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 SDK Support RSS