Session to Session Communications?

If a web app can handle more than one session at a time, is there a way for the Apps sessions to communicate with each other through the App?
i.e. Is there a session array ?

Have a look at the pushexample under Web.

This is quite useful too

Refer to WebApplication.SessionAtIndex, SessionForControl, SessionForControlID, SessionWithIdentifier.

Also, in the July 30th Webinar, I will be covering the Chat sample project which demonstrates the Session Push feature.

The Chat project is available in Examples/Sample Applications/Chat.

Very simple indeed.
However consider this.
I have three pages a session could be showing.

  1. The login page
  2. A user page
  3. An administrators page

In your example you keep an array in the App class of all web pages currently shown.
These are all the same class. This is not the case for my application.

However If I define a class called MyWebPage class that defines a method called message, and all my pages are of the same MyWebPage class then it’s safe to have the App call this message method.

However I’m baffled by how to call the method without keeping an array of each web page.
I thought this might work…

for i=0 to App.SessionCount-1 App.SessionAtIndex(i).CurrentPage.message(txt) next i
…but of course CurrentPage is a WebPage not MyWebPage so the compiler gets upset.

Something like this ought to work:

[code]Dim currPage As WebPage

// Loop through the current page in all the sessions
For i As Integer = 0 To App.SessionCount-1
currPage = App.SessionAtIndex(i).CurrentPage

// Check if MyWebPage is the current page
If currPage IsA MyWebPage Then
// Cast it and then call the method
End If

Ahhh… so that is how you ‘cast’ types in Xojo… Thanks! :slight_smile:

More on Casting is in User Guide Book 1: Fundamentals, Chapter 5: Classes, Section 7: Advanced Class Features.