Jump to content

Inyecting data from the server to a label in a session by id


DonaldShimoda

Recommended Posts

Imagine i have 5 sessions open. Each session have one id stored in a cookie.

I need to change a label dinamically, from the server, in the correct session id.

Example, update temperature value in session with id 1

Is possible? Any hint how to search the session id?

How will refresh at client side(browser)

Best regards

Link to comment
Share on other sites

I use this to close all active sessions from one user (by name) without my own.

 

unisession

var

sUserName : String;

 

 

procedure CloseOtherSesionsFromUser (sesionUser : AnsiString);
var
I : Integer;
U : TUniGUISession;
begin
Try
  UniServerModule.SessionManager.Sessions.Lock;
  for I :=UniServerModule.SessionManager.Sessions.SessionList.Count - 1 downto 0 do begin
      U := UniServerModule.SessionManager.Sessions.SessionList[I];
      //U.LockSession;
      // Check mainModule availability. Some sessions may not have a MainModule instance
      if U.UniMainModule <> nil then begin
        // Do not close my OWN Session
        if (UniApplication.UniSession.SessionID <> U.SessionId)
        AND ((U.UniMainModule as TUniMainModule).sUserName = sesionUser)
        then begin
           U.ReleaseSession;
           U.Terminate ('Already connected: ' + sesionUser + '.'
                        + '</br>' + 'Session is closed');
        end;
         // UniMainModule(U.UniMainModule as TUniMainModule).logout ((U.UniMainModule as TUniMainModule).sUsername); // Access custom MainModule props
      end;
  end;
  UniServerModule.SessionManager.Sessions.Unlock;
Finally

End;
end;

 

You can use sessions list, to search active session.

 

I use other function to search components by extended FindComponent in screen.activeform and change the values

  • Like 1
Link to comment
Share on other sites

13 minutes ago, mhmda said:

Web Sockets will be perfect solution for you.

We already use this tech. in our web app for chat.

I'll see if there is spare time for creating a video tutorial for Unigui + WebScokets (real time app) 🙂

That would be great... can't wait :)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...