Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
owen #1
Member since Nov 2006 · 21 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
Subject: Sending a message - easy question, surely!
Hi.

I'm a newbie so please excuse the dumbness of this question.  I've already searched this Forum and couldn't find the answer.  I am trying to create a very basic VB.NET desktop app to demo the ability to send a message from one Google chat user to another.  I can connect, authenticate, send my presence, and that works fine.

What I am struggling with, is the basic task of sending the message.   The problem being, it just doesn't get there.  But I don't get an error, either.

At this point I am definately connected and authenticated, plus my status shows "Online" at TheRecipient's desktop.

But TheRecipent simply does not recieve the message.  However, my presence shows up in their google IM client correctly.  I think I'm missing something simple here, but I cannot see what it is.

Here's the relevant code; a "Send" button and a "Login" button:
_____________

  Private Sub SendButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendButton.Click
        Dim msg As agsXMPP.protocol.client.Message = New agsXMPP.protocol.client.Message
        msg.Type = MessageType.normal
        msg.Subject = "test subject"
        msg.To = New Jid("TheRecipient", "gmail.com", "owentest")
        msg.Body = "If you can read this, it has worked."
        msg.From = New Jid("MySelf", "gmail.com", "owentest")
        XMPP.Send(msg)  ' <---- where does the message go?  TheRecipient doesn't get it!?!?!
    End Sub

    Private Sub LoginButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginButton.Click
        With XMPP
            Dim cb As New agsXMPP.MessageCB(AddressOf MessageCallback)

            Dim MyJid As New Jid("MySelf", "gmail.com", "owentest")
            .MesagageGrabber.Add(MyJid, cb, Nothing)

            Dim pcb As New agsXMPP.PresenceCB(AddressOf PresenceCallback)
            .PresenceGrabber.Add(MyJid, pcb, Nothing)

            .Server = "gmail.com"
            .ConnectServer = "talk.google.com"
            .Username = "MySelf"
            .Password = "MyPassword"
            .Port = "5222"
            .UseSSL = False
            .Status = "Online"
            .Priority = 5
            .AutoResolveConnectServer = True

            .AutoRoster = True

            .RegisterAccount = False
            .Show = agsXMPP.protocol.client.ShowType.chat
            .Open()

        End With
    End Sub

    Private Sub PresenceCallback(ByVal sender As Object, ByVal pres As agsXMPP.protocol.client.Presence, ByVal data As Object)
        Label1.Text = pres.Nickname.ToString & " status = " & pres.Status
    End Sub

    Private Sub MessageCallback(ByVal sender As Object, ByVal msg As agsXMPP.protocol.client.Message, ByVal data As Object)       
        Label1.Text = msg.From.User & " said: " & msg.Body
    End Sub
___________
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello owen,

Quote by owen:
  Private Sub SendButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendButton.Click
        Dim msg As agsXMPP.protocol.client.Message = New agsXMPP.protocol.client.Message
        msg.Type = MessageType.normal
        msg.Subject = "test subject"
        msg.To = New Jid("TheRecipient", "gmail.com", "owentest")
        msg.Body = "If you can read this, it has worked."
        msg.From = New Jid("MySelf", "gmail.com", "owentest")
        XMPP.Send(msg)  ' <---- where does the message go?  TheRecipient doesn't get it!?!?!
    End Sub

  • msg.From is optional, i wouldn't add it. The server does this on behalf of you. If you add it then you must be sure that it's 100% correct. GoogleTalk normally assigns a resource to your connection, so it will be different than the one you specified when connecting.
  • Are you sure that msg.To is correct? Especially the resource? If not then try to send the message to a bare Jid (without resource).
  • Google drops messages if both contacts are not subscribed to each other. So make sure the subscription is OK on both sites (subscription='both').

Alex
Avatar
Alex #3
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hm, and i never tried to send a message of type = normal to GTalk. So you could also try the chat type.
And the subject is not needed for chat messages.

Alex
Avatar
owen #4
Member since Nov 2006 · 21 posts · Location: UK
Group memberships: Members
Show profile · Link to this post
In reply to post #2
Excellent thank you, Alex. 

Simplifying the Jid and removing the .From property, seemed to do the trick.

Works nicely.
Avatar
Alex #5
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
ok cool.

XMPP is different than the other IM systems here. Because you can login to a xmpp server with the same user id unlimited times. Only the resource has to be different.

That means
  • you can send the message to the full Jid (with resource) of a contact then only this connection receives it
  • or to the bare Jid then the server decides according to the routing rules defined in the XMPP core which connection gets this message.

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