Jump to content

Console Aplication.


docjones

Recommended Posts

Hi

 

I'm trying to create a unigui console standalone application, and it's working fine , no tray icon, and not vcl form interface. (perhaps this is not the best way to create console ungui application but is the only that occurred to me).

 

But have a problem, if i try to change the server port, uniservermodule.port:=xxxx , or server.port, it's not working, always is running on port 8077.

 

I tried to overload uniservermodule constructor, and passing port on constructor Tuniguiservermodule.create(application,port), but same problem, always running on port 8077. How can i do to run on diferent port ?.

 

I attach a example.

 

thanks.

console01.zip

Link to comment
Share on other sites

thanks for your quick answer, solved.

 

but a question, why if i put port=xxxx property on overloaded constructor uniservermodule.create(..), then miss port asigned value in ServerModuleBeforeinit(..). ?, it's a bug?.

 

thanks again.

 

Constructor TUniserverModule.Create(Aowner:Tcomponent;DefaultPort:Integer);
Begin
   Fport:=DefaultPort;
   port:=Fport; //first asignment.
   writeln('Tuniservermodule.Create()  Port='+inttostr(port));
   inherited create(Aowner);
End;


procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject);
begin
 Writeln('Tuniservermodule.BeforeInit()  Port='+inttostr(port));
 if port<>FPort then begin
   Writeln('Detected diferent port than assigned oncreate(), Port='+inttostr(port));
   port:=FPort; //asigned again.
 end;
end;

Link to comment
Share on other sites

  • Administrators

thanks for your quick answer, solved.

 

but a question, why if i put port=xxxx property on overloaded constructor uniservermodule.create(..), then miss port asigned value in ServerModuleBeforeinit(..). ?, it's a bug?.

 

thanks again.

 

Constructor TUniserverModule.Create(Aowner:Tcomponent;DefaultPort:Integer);
Begin
   Fport:=DefaultPort;
   port:=Fport; //first asignment.
   writeln('Tuniservermodule.Create()  Port='+inttostr(port));
   inherited create(Aowner);
End;


procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject);
begin
 Writeln('Tuniservermodule.BeforeInit()  Port='+inttostr(port));
 if port<>FPort then begin
   Writeln('Detected diferent port than assigned oncreate(), Port='+inttostr(port));
   port:=FPort; //asigned again.
 end;
end;

 

TUniGUIServerModule is a TDataModule descendant and it reads properties from DFM file when constructor Create() is called.

 

You can try overriding AfterConstruction for this purpose.

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...