One of the WebPages has URLConnection object in the tray at the bottom, in the ContentReceived event there is some that it is supposed to display message using MessageBox.
Example:
#Pragma Unused URL
#Pragma Unused HTTPStatus
If content.IndexOf("token")>0 Then
Var d As New Dictionary
d = ParseJSON(content)
MessageBox "Token value:" + d.Value("token")
Else
Var vMsg As String = "Password Reset/Invitation " + content
MessageBox vMsg
End If
I can put the breakpoint there and I see the vMsg populated but MessageBox does not work as usual, no message is presented on the screen. This code worked in Xojo2018.
I can place WebLabel with name URLContentLable with the following code:
So… You’re just getting lucky that the label is set correctly. Events of sockets run on the main thread which means the web framework has no way to know which session to send to. I think what you’ll find is that if there was more than one session, the label only gets set some of the time but not all.
You’ll need to either subclass URLConnection so that it knows which session it came from or use a messaging queue so the correct session can pick it up later.
Actually the URLConnection is the super class of WebConnection that belongs to the WebPage in question. I am just looking for confirmation that it is “normal” in Xojo2024R3.1 that the MessageBox is no longer working. If it is “normal” that is OK with me, I can use the label. However, I would like to know for sure rather than make it up on my own
If however this is a bug I would like to report it with the hope that it will be fixed.
You stated that you’re using a URLConnection in the original post. If you are l, try using the WebConnection class instead. That’s probably set up to do what you want.
Greg, the “WebConnection” is just a name of this, the “URLConnection” is the superclass.
There is no build in class with the name “WebConnection”.
add a class to the navigator, call it something you’ll remember.
Set its super to URLConnection
Add a private property mSession as String
Add a Constructor with the code mSession = Session.Identifier
Implement the events and right click on each event and click Create Event Definition from Event (or whatever it’s called)
In each event, you’ll need code like this: Var ctx as new webSessionContext(mSession)
Then you’ll need code to raise the event. So for Error, you’d write: RaiseEvent Error(e)
The context will cause the session to be valid while the context property exists.
From now on you use this class when you need access to the session it came from.
The advantage of doing it this way is that ctx will be nil if the session no longer exists. So if the user closes their browser you can just check to see if session is nil.
I was able to go over the example and learned something new for sure. I just need now to see how to use it in real app.
In the meantime two messages popped up when I was opening your sample project:
Btw,
The first message seems to be confusing to me as I am using latest available Xojo2024R3.1
The second message says something about item no longer supported in my version of Xojo which contradicts the first message.
Greg, thanks again for taking time and providing me with the solution. I have implemented new class into the web app I am working on and the MessageBox now works.