Jump to content

questions about sessions


leandroavila74

Recommended Posts

===[english]===

 

I have a question:

UniServerModule is the main session and global

UniMainModule is the session that belongs to each connection

 

the problem is that if I create a variable in UniMainModule

and increase it in OnCreate and decrease it in OnDestroy

decrements this variable did not!

 

it seems that the session UniMainModule never ends?

 

===[portugues_brazil]===

 

estou com uma dúvida:

UniServerModule é a sessão principal e global

UniMainModule é a sessão que pertence à cada conexão

 

o problema é que se eu criar uma variável em UniMainModule

e incrementar ela no oncreate e decrementar ela no ondestroy

essa variável não decrementa nunca!

 

parece que a sessão de UniMainModule nunca termina?

Link to comment
Share on other sites

===[english]===

 

I have a question:

UniServerModule is the main session and global

UniMainModule is the session that belongs to each connection

 

the problem is that if I create a variable in UniMainModule

and increase it in OnCreate and decrease it in OnDestroy

decrements this variable did not!

 

it seems that the session UniMainModule never ends?

 

===[portugues_brazil]===

 

estou com uma dúvida:

UniServerModule é a sessão principal e global

UniMainModule é a sessão que pertence à cada conexão

 

o problema é que se eu criar uma variável em UniMainModule

e incrementar ela no oncreate e decrementar ela no ondestroy

essa variável não decrementa nunca!

 

parece que a sessão de UniMainModule nunca termina?

 

Leandro,

 

Também estou testando as funcionalidades de sessão do UniGUI, pois utilizo atualmente o IntraWeb, que possui bastante semelhança com este.

 

Aqui nos meus testes, o uso do "MainModule" como controlador da sessão está funcionando corretamente, de modo que se eu coloco uma variável (por exemplo) nele e atribuo algo no OnCreate do MainModule, funciona correto e se fizer algo no OnDestroy também está funcionando.

 

Vou postar aqui um exemplo do que estou utilizando no MainModule que pode te ajudar:

Nesse exemplo estou usando os eventos "Create" e "Destroy" para atribuir um número para a sessão e também para saber quando inicia a sessão e termina podendo exibir num outro form da aplicação uma lista das sessões. (Estou considerando o uso de modo StandAloneServer).

 

type
 TUniMainModule = class(TUniGUIMainModule)
   procedure UniGUIMainModuleCreate(Sender: TObject);
   procedure UniGUIMainModuleDestroy(Sender: TObject);
 public
   IDSecao: String;
   TimeStart: TDateTime;
   Session: TUniGUISession;
 end;

(...)

implementation

(...)

var Count: Integer = 0;

procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject);
begin
   Inc(Count); // incrementa o Count
   IDSecao := 'sec' + IntToStr(Count); // grava em IDSecao o numero da sessao

   TimeStart := Now;
   Session := UniSession;

   FrmMon.Add(Self); // funcao de outro form para adicionar a Sessao numa Lista
end;

procedure TUniMainModule.UniGUIMainModuleDestroy(Sender: TObject);
begin
   FrmMon.Del(Self); // funcao de outro form para deletar a Sessao numa Lista
end;

Link to comment
Share on other sites

Importante lembrar também o seguinte:

 

Você está falando de sessões iniciadas pelo Browser certo? (ou sessão da VCL ?)

 

Se for sessão do Browser, lembre-se de que a sessão só termina no TimeOut (padrão 10 minutos) ou se tiver um botão nos forms da aplicação que force o término da sessão.

Link to comment
Share on other sites

Out of Thread !!!

 

If would be possible to write in English, it would be good for everybody. All we are here to learn. I understood the explanation because I speak Spanish as my first language and it is more less the same, but may be the are other people that could not understand and wants to know about it. Of course, for you both it is better in Portugues, I understand, but thinking about community is not the better choice.

 

It is my opinion.

Link to comment
Share on other sites

Sorry, here goes the explanation in English:

 

I'm testing the UniGUI "sessions" features too, because I actualy use IntraWeb, that have a very similar way to handle sessions.

 

In my tests, the use of the "MainModule" as session control is working properly, so that I use "OnCreate" and "OnDestroy", they are correctly fired when the session starts and ends.

 

To ilustrate this feature, I will post here a piece of code that well represents the use of sessions in UniGUI:

 

type
 TUniMainModule = class(TUniGUIMainModule)
   procedure UniGUIMainModuleCreate(Sender: TObject);
   procedure UniGUIMainModuleDestroy(Sender: TObject);
 public
   IDSession: String;
   TimeStart: TDateTime;
   Session: TUniGUISession;
 end;

(...)

implementation

(...)

var Count: Integer = 0;

procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject);
begin
   Inc(Count); // increments the Count
   IDSession := 'sec' + IntToStr(Count); // write IDSession with the session number

   TimeStart := Now;
   Session := UniSession;

   FrmMon.Add(Self); // function of another form that add the session to a list
end;

procedure TUniMainModule.UniGUIMainModuleDestroy(Sender: TObject);
begin
   FrmMon.Del(Self); // function of another form that removes the session from a list
end;

 

In addition there are many other routines that can be made ​​in the control session, which I'm doing some testing here.

 

And just remember: I am considering the use of UniGUI in StandAloneServer mode, where the session control is most needed.

 

Remembering also that the session ends only when ocurrs the timeout (default 10 minutes), or if the session is terminated manualy.

So the event "OnDestroy" of "MainModule" is only fired in this cases.

 

All this was concluded from tests.

Please, correct me if I'm wrong.

Thanks.

Link to comment
Share on other sites

  • Administrators

I have a question:

UniServerModule is the main session and global

UniMainModule is the session that belongs to each connection

 

the problem is that if I create a variable in UniMainModule

and increase it in OnCreate and decrease it in OnDestroy

decrements this variable did not!

 

it seems that the session UniMainModule never ends?

 

OnDestroy is called when session is timeout or destroyed by closing MainForm.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...