Dim locApplicationServer As New ApplicationServer("myServer")
locApplicationServer.NetworkServer.ServerChannel = New IpHttpServerChannel()
locApplicationServer.NetworkServer.Port = 8099
locApplicationServer.NetworkServer.SessionManager = New SessionExtensions.SessionManager()
locApplicationServer.Run(myArguments)
Where the “SessionExtensions.SessionManager” is really basic at the moment:
Imports RemObjects.SDK.Server
Namespace SessionExtensions
Friend Class SessionManager
Inherits MemorySessionManager
Public Overrides Sub DestroySession(sessionId As Guid)
MyBase.DestroySession(sessionId)
End Sub
Protected Overrides Function CreateNewSession(sessionId As Guid) As ISession
Return MyBase.CreateNewSession(sessionId)
End Function
Protected Overrides Sub TriggerOnSessionCreated(e As SessionEventArgs)
MyBase.TriggerOnSessionCreated(e)
End Sub
Protected Overrides Sub TriggerOnSessionDestroyed(e As SessionIDEventArgs)
MyBase.TriggerOnSessionDestroyed(e)
End Sub
Protected Overrides Sub TriggerOnSessionExpired(e As SessionEventArgs)
MyBase.TriggerOnSessionExpired(e)
End Sub
End Class
End Namespace
Now, when I run the program and in my login comes to the following code snipset:
<ServiceMethod>
Public Function LogIn(LoginString As String) As Boolean
Session(SessionExtensions.Names.UserId) = "Test"
Session(SessionExtensions.Names.LoginTime) = DateTime.UtcNow
Return True
End Function
Then I would expect, that the “Protected Overrides Function CreateNewSession(sessionID as Guid) as ISession” is getting called, because there is no session, which exists. So it must get created.
Am I missung soemthing?
I want to create some kind of loggin, when Session events happen.
Or could you give me some kind of sample, how I can do this correct!?
You are right. The session should be created when this code line is executed:
Session(SessionExtensions.Names.UserId) = "Test"
For services like LoginService that do not require authorization to be accessed sessions are created or accessed lazily, only at the moment when they are accessed by the service method code.
I tried your code and it seem to work.
Could you send a testace to support@ so we’ll investigate if something is missing form your code?
Yes, you are rigt, the code works as expected. The problem was, that the Breakpoint within the „TriggerOnSessionCreated“ routine was not fired.
When I surround it by some Console.WriteLine Code, then I can see the result as expected.
Have you seen the code generation problem, I added tot he project?
Oh…
I have sended a test project yesterday to the support@ email address.
And with this mail & testcase I wrote:
Please take a look into the autogenerated file: „Opt_Studio_ServerAccess.vb“
I have commented the generated code out, because the template creates a wrong file.
The Imports does not get a new line
The Imports statement does not use the correct Namespace
The Interfaces are not allowed to have a prefix like Private (in Visual Basic)
The routines must have a Implements statement to get recognized as part of the Interface
Ah, yes
Sorry, the text was hidden by the mail parser and I looked more for the SessionManager part.
Yes, it seems there are issues with the code generation here. Please note that _Intf and _ServerAcces files are generated by different code generation engines, so -Intf code is not affected by these issues
You are right
One more thing, what isn’t working with the ServerAccess files:
It seems, it is not regenerating, when the RODL changes.
I was able to add the complex type now, after changing it to Array as you provided a few minutes ago.
But, when I right click on the RODL and Update files, then the _Intf is updated, but not the ServerAccess
As expected. _ServerAccess and _Impl files are not regenerated on RODL changes. _Impl files contain service implementation code, so it is basically not possible to regenerate them without risking to lose user code _ServerAccess code file serves as a starting point which is meant to be adjusted (or even deleted at all) by the user. This file is not even required to access the server.