Jump to content

docjones

uniGUI Subscriber
  • Posts

    117
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by docjones

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

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

  3. There is an Entry Point where you place your Login and Pwd and then appear a Screen with Links to other modules. You can access directly to different modules using the url:port schema but if the system detect that you have not a session opened show you the login form for opening new one independently of module you are get in. The app's session data is stored in the db and use virtual stations for that.

     

    i'm interested in how you do this :).

    you saved session login information on bd, but, how do you detect in second module that user is not logged in ?, using cookies ? user ip ?, passing to second module parameters like sessionid and cheking bd?.

     

    thanks.

  4. Doing balancing inside UniGui app is weird, but if you desire...

     

    procedure TMainForm.UniButton1Click(Sender: TObject);
    begin
     UniServerModule.ServerMessages.TerminateTemplate.Text := '<script>location.href=''http://google.com''</script>';
     Close;
    end;
    

     

    Thanks, this is exactly i want to do.

    now, if too users are connected to primary server, my unigui app can control user sessions and redirect to another host . and i can do the same on the secondary server.

  5. Hi all.

     

    first, sorry for my poor english

    I'm playing with unigui, and i'm trying to balance user sessions into two unigui applications (hosted on same or diferent server).

     

    when user connect to primay server (localhost:8077), and sessions count >n , then i want terminate the user session, and redirect to second server like (localhost:8088).

     

    this is the code.

     

    Mainmodule.

     

    type
     TUniMainModule = class(TUniGUIMainModule)
       procedure UniGUIMainModuleCreate(Sender: TObject);
       procedure UniGUIMainModuleDestroy(Sender: TObject);
     private
       { Private declarations }
    
     public
       { Public declarations }
       Intime:tdatetime;
       Session:TUniGuiSession;
       Redirect:boolean;
     end;
    
    implementation
    
    {$R *.dfm}
    
    uses
     UniGUIVars, ServerModule;
    
    //when session starts.
    procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject);
    begin
     Intime:=now;
     Session:=UniSession;
     Redirect:=false;
     UniServerModule.newsession(Self);
    end;
    
    //when session end.
    procedure TUniMainModule.UniGUIMainModuleDestroy(Sender: TObject);
    begin
      UniServerModule.EndSession(Self)
    end;
    

     

     

    ServerModule

    
    TUniServerModule = class(TUniGUIServerModule)
     private
       { Private declarations }
       procedure KillSession;
     protected
       procedure FirstInit; override;
     public
       { Public declarations }
        sessioncount:integer;
        procedure NewSession(MModule:  TUniMainModule);
        procedure EndSession(MModule: TUniMainModule);
     end;
    
    
    implementation
    
    {$R *.dfm}
    
    uses
     UniGUIVars;
    
    Procedure Uni_Redirect(Sesion:TUniGUISession;Url:string);
    var Cad:string;
    Begin
       Cad:='location.href='''+url+'''';
       Sesion.AddJS(Cad);
    End;
    
    procedure TUniServerModule.NewSession(MModule:  TUniMainModule);
    Begin
       //add session count.
      inc(sessioncount);
      if sessioncount>2 then begin //if > max allowed, then redirect.
         MModule.Redirect:=true;
         Uni_Redirect(Mmodule.Session,'http://localhost:8088');
      end;
    End;
    
    procedure TUniServerModule.EndSession(MModule: TUniMainModule);
    Begin
     Dec(sessioncount);
    End;
    

     

    If i do a redirect (uni_redirect) on new session, then url redirect is not working

     

    and, if i try to redirect on mainform.create , then redirect is working, but can't terminate the session

     

    procedure TMainForm.UniFormCreate(Sender: TObject);
    begin
    if UniMainModule.Redirect then begin
     Uni_Redirect(UniSession,'http://localhost:8088');
     //Unisession.UniApplication.Terminate;// can't do this, becouse not redirected.
    end;
    end;
    
    

     

     

    Then, how can i do redirect, and terminate session ? or this is not possible ?

     

    Thanx

×
×
  • Create New...