NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Rhys Daniell on July 25, 2007, 03:42:40 PM
-
I need to the number of concurrent operators, so I need a way to detect whether a user is currently logged in and active.
I suspect the simplest and most effective way of doing this is to use a timer to update a control file at regular intervals.
I notice the NetWebSource template allows a timer to be turned on. How do I get access to the timer 'event'? If I use this timer in the standard page footer will it be available on all pages?
TIA
Rhys
-
Rhys,
All requests get routed through the WEBHANDLER() procedure.
IN particular, every request goes through the
NetWebServerWorker.ProcessLink method.
I'm using this method to lookup the user and switch the date picture between @D2 and @D6, and also to disconnect, change ownername, and reconnect to SQL database which is correct for this user.
I think you would probably want to use the same ProcessLink method and record the activity from here.
Regards,
Alan
-
Hi Alan,
to switch SQL databases do you just create a session variable when the user logs on of what DB they use and then as you pass through this embed to connect to that DB?
I'm currently running 2 exe's on 2 ports to support multiple DB's but I can see this getting messy as we roll out more DB's.
If you have time I would love to see what code you have in the process link embed to achieve this...
Cheers,
Kevin
-
Hi Rhys,
There are 2 approaches to this.
The first is to put a "timer" into the web page so that you can see the timer, and work from there.
This is a bit icky though. Firstly you're generating extra traffic, and of course it doesn't tell you if the user just left their browser on that page overnight.
A better approach is to make use of the Session Queue. By querying this at regular intervals you can take "snap shots" of who is online, and who is not.
Better yet, all you really need to trap is
a) when the user logs in and
b) when he either logs out, or the session automatically terminates.
The first part is easy to do (since you have to manage the login anyway).
The second bit is also easy, if a bit cunning.
the WebServer procedure contains an object based on the NetWebServer class. So in this is a method called _DeleteSession.
This method is called whenever a session is deleted (meaning it has been inactive for a period of time). So in this method, before the parent call, you can add any code you like.
At that point you've got to be a bit careful, because you're working inside the server (which is shared.) Plus the normal GetSessionValue changes to _GetSessionValue so the code would look something like this;
err Long
x = self._GetSessionValue(p_SessionID,'whatever',err)
if err = 0
! do something with x
end
cheers
Bruce
-
Kevin,
On the login screen I lookup a local TPS file for that user and save to session queue:
p_web.SetSessionValue('glo:ownername','loc:Ownername')
p_web.SetSessionValue('glo:driveroption','loc:DriverOption;)
Then in webhandler ThisNetWorker.ProcessLink I retrieve these saved values from session queue:
if ThisNetWorker.GetSessionLoggedIn()<>0
loc:Ownername = ThisNetWorker.getSessionValue('glo:ownername')
loc:driveroption = ThisNetWorker.getSessionValue('glo:driveroption')
! then switch databases
SqlFile{Prop:Disconnect}
SqlFile{prop:logonscreen} = false
GLO:OwnerName = loc:OwnerName
GLO:DriverOption = loc:driveroption
! now test open a file
open(SqlFile,0h) !reaonly mode
if errorcode()
! write to errorlog
end
close(SqlFile)
end !
Hope this helps,
Alan