Webcontainer issue

Hello All,

I have a REST web application. My client application has two web-container screens. The first web-container is opened in the open event of the web page. Until here no problem.
When the client application receives a response from the web server application, the page received event of my HTTPSecureSocket is triggerd and a method is called. In this method the following is done;

if self.content <> Nil then
self.Content.Close
self.Content = Nil
end if
Try
Dim wc As New SecondWebContainer
Catch
End Try

content is defined as web-container property of the web page. The problem is caused by “Dim wc As New SecondWebContainer” .
The application is totaly frozen.
This behavior is caused only when the HTTPSecureSocket page received event is involved.

Did someone encounter this issue? or does anyone know a solution for this problem. Tried all versions of xojo, all the same problem.

Events in the httpsecuresocket fire on the main thread, so there’s no concept of a session at that point. That’s probably why you can’t create a new instance if the webcontainer.

Thanks Greg,

The event of the httpsecuresocket fires a method of the web page. httpsecuresocket and the methods are all part of the same web page.
What do you suggest is a proper solution in this situation?
I must be able to display a second/third/etc… webcontainer. At the moment I have no clue how to do that.

Thanks,

The proper solution requires an understanding of how things work in the background…

Every request that comes in from a browser is run in a thread. Each thread is associated with a particular session. We use that relationship ( thread to session ) to make sure everything stays in sync with your code executing things against the correct session.

Now… Because sockets execute their events on the main thread, the code can’t be associated with a particular session without some help. My suggestion is to subclass the Httpsecuresocket so that you can include a reference ( or better yet, a weak ref ) to the session in which it is created and then use the session to set up a new connection when your code runs later.

The way to reconnect to the session is to create a new WebSessionContext object in that event and pass in the reference t the current session.

Hi Greg,

My HTTPSecureSocket is sub-classed and is connected to my only web page. I want to be able to address other controls on that same web page from the page received event of the socket. The system does not even let me assign text to a field on that same web page.
I really don’t want to get that complicated. Please let me have a sample of code how to do that.

Thanks again.

There’s no way to uncomplicate this. The HTTPSecureSocket (as well as any of the other sockets that are subclassed from TCPSocket or SSLSocket) fires on the main thread.

There is an example of using WebSessionContexts in the Examples/Web folder.

Thanks Greg,

I have been able to work around this by using synchronous POST. Before I was using asynchronous POST, that didn’t give me the solution I wanted.
I will look into the example you mentioned. Hopefully I can find what I need in there.

Thanks,