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.
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.
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
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
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.