Extension of SessionManager

I start the Application Server like follows:

   Dim locApplicationServer As New ApplicationServer("myServer")

    locApplicationServer.NetworkServer.ServerChannel = New IpHttpServerChannel()
    locApplicationServer.NetworkServer.Port = 8099
    locApplicationServer.NetworkServer.SessionManager = New SessionExtensions.SessionManager()

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)

    End Sub
    Protected Overrides Function CreateNewSession(sessionId As Guid) As ISession
        Return MyBase.CreateNewSession(sessionId)
    End Function
    Protected Overrides Sub TriggerOnSessionCreated(e As SessionEventArgs)
    End Sub
    Protected Overrides Sub TriggerOnSessionDestroyed(e As SessionIDEventArgs)

    End Sub
    Protected Overrides Sub TriggerOnSessionExpired(e As SessionEventArgs)
    End Sub

End Class

End Namespace

Now, when I run the program and in my login comes to the following code snipset:

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!?

THX a lot in advance


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?

Thanks in advance

I have send to you an example project.
THX - Harald


Thanks for the testcase.
However as far as I can see it works perfectly fine without any changes in code.

Hey antonk!

  1. 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.
  2. Have you seen the code generation problem, I added tot he project?

THX a lot in advance

I am afraid not. Where exactly is the problem?

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.

  1. The Imports does not get a new line
  2. The Imports statement does not use the correct Namespace
  3. The Interfaces are not allowed to have a prefix like Private (in Visual Basic)
  4. 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

Thanks, logged as bugs://85139

You are right :wink:
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.

Okay, thx for clarification