Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Page: previous  1  2 
Avatar
Jabberer #16
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
In reply to post ID 1359
you must invoke all event handlers from agsXMPP. Because of threading issues in Windows.Forms. In the MiniClient code you can see how this works.
Software Developer
AG-Software
Avatar
Jabberer #17
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
here you can find a working port of MiniClient to WM5.
https://genie.iitd.ernet.in/wiki/index.php/A_Jabber_based_…
Software Developer
AG-Software
Avatar
Slick #18
Member since Sep 2006 · 14 posts
Group memberships: Members
Show profile · Link to this post
Thanks Jabberer

I downloaded the project files from that link only to find out its for linx system its a Client.tar.gz file lol
Avatar
Alex #19
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
no this code is for Windows-VS2005. You should be able to open the archive with 7Zip, WinRar, WinZip and others.

Alex
Avatar
Slick #20
Member since Sep 2006 · 14 posts
Group memberships: Members
Show profile · Link to this post
Thanks once again guys

Ive downloaded the project files and unziped it. Now this is going to sound strange but for some weird reason i can only send messages from the PocketPC to my software but when i send one from my software back to the pocketPC it errors. Note: the pocketpc is running the client application that i downloaded today. I thought maybe i did something wrong from my software so i then decided to bypass using my software so i deployed the client application above to 2 different PocketPC's and tried communicating. When i send a message from PocketPC1 to PocketPC2, PocketPC1 sends the message alright but when it gets to PocketPC2 it generates the following error

Client.exe
ArgumentException
An error Message cannot be displayed because an optional resource assembly containing it cannot be found

at System.Collections.Hashtable.Insert()
at System.Collections.Hashtable.Add()
at MiniClient.frmChat..ctor()
at MiniClient.frmMain.XmppCon_OnMessage()
at System.Reflection.RuntimeMethodInfo.internalInvoke()
at System.Reflection.RuntimeMethodInfo.internalInvoke()
at System.Reflection.RuntimeMethodInfo.Invoke()
at System.Rreflection.MethodBase.Invoke()
at TASK.invoke()
at System.Windows.Forms.Contorl._InvokeAll()
at System.Windows.Forms.Contorl.WinProc()
at System.Windows.Forms.ContainerContorl.WinProc()
at System.Windows.Forms.Contorl.WinProc()
at System.Windows.Forms.Contorl._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMAinLoop()
at System.Windows.Forms.Application.Run()
at MiniClient.frmMain.Main()

I have no clue what the above error message means.
Avatar
Alex #21
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
this is a threading problem. Please invoke the OnMessage event correctly.
I took a quick look at this code and it's not correct. Thats the reason why it crashes. Please look in the MiniClient how you invoke the event handers correctly.
We are working on a WM5 example which will be released soon.

Alex
Avatar
Slick #22
Member since Sep 2006 · 14 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex
Sorry to be a pain but the error message i posted above was not from my code i posted earlier. Its from the Miniclient download that Jabberer gave me the link to https://genie.iitd.ernet.in/wiki/index.php/A_Jabber_based_…  

Do u have idea on the timescale for the WM5 example?
Here is my updated code below.

Private WithEvents conn As New agsXMPP.XmppClientConnection

    Dim Jid As agsXMPP.Jid

    Private Sub OutgoingMessage(ByVal msg As agsXMPP.protocol.client.Message)
       
        txtMessage.Text = msg.Body

    End Sub

    Public Sub IncomingMessage(ByVal msg As agsXMPP.protocol.client.Message)

        lstMessage.Items.Add(msg.Body)

    End Sub

    Private Sub MessageCallback(ByVal sender As Object, ByVal msg As agsXMPP.protocol.client.Message, ByVal data As Object)
        IncomingMessage(msg)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim cb As agsXMPP.MessageCB
        Dim user As String = "olu2020Fleet@trakm8.net"

        With conn

            Jid = New agsXMPP.Jid("olu2020Fleet@trakm8.net")
            cb = New agsXMPP.MessageCB(AddressOf MessageCallback)
            Util.Forms.Add(Jid.Bare.ToLower(), Me)
            .MesagageGrabber.Add(Jid, cb, Nothing)
            .SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct
            .Server = "athena.trakm8.net"
            .Username = "oluxda2020Fleet"
            .Password = "oluxda"
            .Port = "5222"
            .Status = "Online"
            .Priority = 5
            .Show = agsXMPP.protocol.client.ShowType.NONE
            .Open()
        End With
    End Sub

    Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click
        Dim msg As agsXMPP.protocol.client.Message = New agsXMPP.protocol.client.Message
        msg.Type = agsXMPP.protocol.client.MessageType.chat
        msg.To = Jid
        msg.Body = txtMessage.Text
        conn.Send(msg)
        OutgoingMessage(msg)
        txtMessage.Text = ""
    End Sub

    Private Sub BtnLogoff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogoff.Click
        'conn.Close()
        Me.Close()
    End Sub

    Private Sub conn_OnError(ByVal sender As Object, ByVal ex As System.Exception) Handles conn.OnError
        MsgBox(ex.Message)
    End Sub

    Private Sub conn_OnLogin(ByVal sender As Object) Handles conn.OnLogin
        MsgBox("Logged on")
    End Sub

    Private Sub conn_OnMessage(ByVal sender As Object, ByVal msg As agsXMPP.protocol.client.Message) Handles conn.OnMessage
        IncomingMessage(msg)
    End Sub

    Private Sub conn_OnRosterEnd(ByVal sender As Object) Handles conn.OnRosterEnd
        conn.Show = agsXMPP.protocol.client.ShowType.NONE
        conn.SendMyPresence()
    End Sub
Avatar
Jabberer #23
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Hello,

Alex checked this code yesterday evening and told me it's buggy. I'm sorry, its not the best example.

You have to Incoke your Events and Callbacks

Code (untested):
Private Sub MessageCallback(ByVal sender As Object, ByVal msg As agsXMPP.protocol.client.Message, ByVal data As Object)

    If InvokeRequired Then
        BeginInvoke(CType(AddressOf MessageCallback, MessageCB), New Object() {sender, msg, data})
        Return
    End If

    IncomingMessage(msg)
End Sub
Software Developer
AG-Software
Avatar
Slick #24
Member since Sep 2006 · 14 posts
Group memberships: Members
Show profile · Link to this post
Thanks very much guys and i would like to take this oppurtunity to apologise for being a pain in the back side :) I'm new to .NET programming  and didnt realise that
If InvokeRequired Then
        BeginInvoke(CType(AddressOf MessageCallback, MessageCB), New Object() {sender, msg, data})
        Return
End If

Could make a difference lol. My program is working fine now thanks to the Jabber Lords Alex and Jabberer

Im well chuffed! :)

Thanks very much guys and I'm sorry for all the pain ive caused

Slick
Avatar
Alex #25
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Windows Forms are not thread safe. The library makes use of async communication models which means all events are raised from another thread than your main GUI thread.
You have to Invoke all events from agsXMPP to avoid this issues.
Its will be exactly the same when you use multiple threads inside you application which update the GUI.

Alex
Avatar
Alex #26
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi,

the MiniClient WM5 sample is released.
Its included in the agsXMPP SDK and available for download.

Alex
Avatar
Slick #27
Member since Sep 2006 · 14 posts
Group memberships: Members
Show profile · Link to this post
Thanks Alex.

Is there a link to where i can download it or i have to download the whole SDK again?
Avatar
Alex #28
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You have to download the SDK again.

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