Jump to content

Recommended Posts

Posted

Currently I use HyperServer, I would like to know if there is any event to notify the user that there is a new version of the system,

for him to leave the system and enter again. It is possible?

Posted
3 hours ago, picyka said:

Currently I use HyperServer, I would like to know if there is any event to notify the user that there is a new version of the system,

for him to leave the system and enter again. It is possible?

We don't have any event for this.

You can create a logic to check a field in database. When you upload new version, you can change it and notify customers.

Posted
8 minutes ago, Hayri ASLAN said:

We don't have any event for this.

You can create a logic to check a field in database. When you upload new version, you can change it and notify customers.

using the hyperserver, is there a way to notify the sessions? or would have to wait for websocckets

Posted
Há 1 hora, Hayri ASLAN disse:

Você precisa esperar por websockets

Two questions:

 

Is there any way for me to know what is the current version of the session I'm in?

 

How to use this code in unigui?

<script type="text/javascript">
	
	const socket = new WebSocket('ws://localhost:8080');

	socket.addEventListener('open', function (event) {
		socket.send('Hello Server!');
	});

	socket.addEventListener('message', function (event) {
		var today = new Date();
		var date = String(today.getDate()).padStart(2, '0') + '/' + String(today.getMonth() + 1).padStart(2, '0') + '/' + today.getFullYear();
		var time = String(today.getHours()).padStart(2, '0') + ":" + String(today.getMinutes()).padStart(2, '0') + ":" + String(today.getSeconds()).padStart(2, '0');
		var dateTime = date+' '+time;	
		$("#log").append(
			"<tr>" +
				"<th>" + dateTime + "</th>" +		
				"<th>" + event.data + "</th>" +
			"</tr>"
		);			
	});

	function sendMessage() {		
		socket.send(document.getElementById("textMessage").value);	
	};

</script>

GitHub - mateusvicente100/bird-socket-server: Este é um servidor websocket para Delphi.

Posted
Há 1 hora, Picyka disse:

Duas perguntas:

 

Há alguma maneira de eu saber qual é a versão atual da sessão em que estou?

 

Como usar esse código no unigui?

<script type="text/javascript">
	
	const socket = new WebSocket('ws://localhost:8080');

	socket.addEventListener('open', function (event) {
		socket.send('Hello Server!');
	});

	socket.addEventListener('message', function (event) {
		var today = new Date();
		var date = String(today.getDate()).padStart(2, '0') + '/' + String(today.getMonth() + 1).padStart(2, '0') + '/' + today.getFullYear();
		var time = String(today.getHours()).padStart(2, '0') + ":" + String(today.getMinutes()).padStart(2, '0') + ":" + String(today.getSeconds()).padStart(2, '0');
		var dateTime = date+' '+time;	
		$("#log").append(
			"<tr>" +
				"<th>" + dateTime + "</th>" +		
				"<th>" + event.data + "</th>" +
			"</tr>"
		);			
	});

	function sendMessage() {		
		socket.send(document.getElementById("textMessage").value);	
	};

</script>

GitHub - mateusvicente100/bird-socket-server: Este é um servidor websocket para Delphi.

UniSession.AddJS('socket.send('''+Self.UniEdit1.Text+''');');

 

Posted
	socket.addEventListener('message', function (event) {    
     alert(event.data); 
     ajaxRequest(MainForm.JSName, "Message", event.data);
	});

How to put ajaxRequest to get the data coming from the server in the events?

Posted
51 minutos atrás, Picyka disse:
	socket.addEventListener('message', function (event) {    
     alert(event.data); 
     ajaxRequest(MainForm.JSName, "Message", event.data);
	});

Como colocar ajaxRequest para obter os dados provenientes do servidor nos eventos?

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniSession.AddJS('socket.addEventListener(''message'', function (event) { ' +
     '  alert(event.data); ' +
     '  ajaxRequest('+Self.WebForm.JSName+', "_socket", [''text='' + event.data]); ' +
	   '});');
end;

 

Posted
16 hours ago, picyka said:

Is there any way for me to know what is the current version of the session I'm in?

Hello, maybe You need to know this on HyperServer, but You can use this on serverSide.

UniMainModule

  type
    TAppVer = record
      majVer,
      minVer,
      RelVer,
      BuildVer  : String;
  end;

var

AppVer                : TAppVer;
 

//get version of App

FUNCTION GETFILEVERSION : string;
var
  VInfoSize, DetSize      : DWord;
  pVInfo, pDetail         : Pointer;
  pLangInfo               : ^TLangInfoBuffer;
  strLangId, s            : string;
begin
  s := Application.ExeName;
  VInfoSize := GetFileVersionInfoSize (
    PChar (s), DetSize);
  if VInfoSize > 0 then
  begin
    GetMem (pVInfo, VInfoSize);
    TRY
       GetFileVersionInfo (PChar (s), 0,
         VInfoSize, pVInfo);
       // show the fixed information
       VerQueryValue (pVInfo, '\', pDetail, DetSize);
       with TVSFixedFileInfo (pDetail^) do begin
            RESULT := IntToStr (HiWord (dwFileVersionMS)) + '.'
                      + IntToStr (LoWord (dwFileVersionMS)) + '.'
                      + IntToStr (HiWord (dwFileVersionLS)) + '.'
                      + IntToStr (LoWord (dwFileVersionLS));
           //separate information
           AppVer.majVer := IntToStr (HiWord (dwFileVersionMS));
           AppVer.minVer := IntToStr (LoWord (dwFileVersionMS));
           AppVer.RelVer := IntToStr (HiWord (dwFileVersionLS));
           AppVer.BuildVer := IntToStr (LoWord (dwFileVersionLS));
       end;
    FINALLY
      FreeMem (pVInfo);
    END;
  end;
  Result := AppVer.majVer + '.' + AppVer.minVer + '.' + AppVer.RelVer + '.' + AppVer.BuildVer;
end;

 

procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject);
begin

GETFILEVERSION;

end;

 

//Access custom MainModule props Your function

Try
  SessionManager.Sessions.Lock;
  for I := SessionManager.Sessions.SessionList.Count - 1 downto 0 do begin
    Try
      U := SessionManager.Sessions.SessionList[I];
      //U.LockSession;
      // Check mainModule availability. Some sessions may not have a MainModule instance
      if U.UniMainModule <> nil then begin

        //show message with version of App

         (U.UniMainModule as TUniMainModule).ShowAlert ((U.UniMainModule as TUniMainModule).AppVer); // Access custom MainModule props
         TRY
         //U.LockSession;
         //U.ReleaseSession;
         U.Terminate('');
         FINALLY
            //U.UnBusy;
         END;

      end;
    Except
        on E:Exception do begin
        end;
    End;
  end;
  SessionManager.Sessions.Unlock;
Except
  on E:Exception do begin
  end;
End;
 

 

OR just save that info in Cookie

Posted
6 hours ago, irigsoft said:

Olá, talvez você precise saber disso no HyperServer, mas você pode usar isso no serverSide.

UniMainModule

tipo
TAppVer = gravar
majVer,
minVer,
RelVer,
BuildVer : String;
fim;

Var

AppVer                : TAppVer;
 

obter versão do App

FUNÇÃO GETFILEVERSION : string;
var
VInfoSize, DetSize : DWord;
pVInfo, pDetail : Ponteiro;
pLangInfo : ^TLangInfoBuffer;
strLangId, s: string;
iniciar
s := Application.ExeName;
VInfoSize := GetFileVersionInfoSize (
PChar (s), DetSize);
se o VInfoSize > 0, então
inicie o
GetMem (pVInfo, VInfoSize);
TENTE
GetFileVersionInfo (PChar (s), 0,
VInfoSize, pVInfo);
// mostrar as informações
fixas VerQueryValue (pVInfo, '\', pDetail, DetSize);
com TVSFixedFileInfo (pDetail^) começam
RESULTADO := IntToStr (HiWord (dwFileVersionMS)) + '.'
+ IntToStr (LoWord (dwFileVersionMS)) + '.'
+ IntToStr (HiWord (dwFileVersionLS)) + '.'
+ IntToStr (LoWord (dwFileVersionLS));
//informações separadas
AppVer.majVer:= IntToStr (HiWord (dwFileVersionMS));
AppVer.minVer := IntToStr (LoWord (dwFileVersionMS));
AppVer.RelVer := IntToStr (HiWord (dwFileVersionLS));
AppVer.BuildVer := IntToStr (LoWord (dwFileVersionLS));
fim;
FINALMENTE
FreeMem (pVInfo);
FIM;
fim;
Resultado := AppVer.majVer + '.' + AppVer.minVer + '.' + AppVer.RelVer + '.' + AppVer.BuildVer;
fim;

 

procedimento TUniMainModule.UniGUIMainModuleCreate(Remetente: TObject);
começar

GETFILEVERSION;

fim;

 

//Acesse os adereços personalizados do MainModule Sua função

Tente
SessionManager.Sessions.Lock;
para I := SessionManager.Sessions.SessionList.Count - 1 down a 0 iniciar Try

U := SessionManager.Sessions.SessionList[I];
//U.LockSession;
// Verifique a disponibilidade do mainModule. Algumas sessões podem não ter uma instância
do MainModule se o U.UniMainModule <> zero, então começar

        //mostrar mensagem com versão do App

(U.UniMainModule como TUniMainModule). ShowAlert ((U.UniMainModule como TUniMainModule). AppVer); // Acesse os adereços personalizados
do MainModule TRY
//U.LockSession;
//DivulgaçãoSessão;
U.Terminate('');
FINALMENTE
//U.UnBusy;
FIM;

fim;
Exceto
em E:Exception começar o
fim;
Fim;
fim;
SessionManager.Sessions.Unlock;
Exceto
em E:Exception começar o
fim;
Fim;

 

 

OU apenas salvar essa informação em Cookie

Good morning friends, yeah, if I don't know which version my session is, I can't do anything. I don't know if we have this information, It seems that when I use HyperServer some functions are missing.

Posted
5 minutes ago, picyka said:

Good morning friends, yeah, if I don't know which version my session is, I can't do anything. I don't know if we have this information, It seems that when I use HyperServer some functions are missing.

Hi, I shared my function to retrieve the version of my unigui app and how to store and read it in AppVer variable, but then I thought that you can store this information in a cookie for each session and read this cookie during on execution or when the session is created

  • Upvote 1
Posted
1 hour ago, irigsoft said:

Hi, I shared my function to retrieve the version of my unigui app and how to store and read it in AppVer variable, but then I thought that you can store this information in a cookie for each session and read this cookie during on execution or when the session is created

Thanks for your attention,

I'll try something here Thanks

  • 2 weeks later...
Posted
On 8/17/2022 at 4:03 PM, picyka said:

Thanks for your attention,

I'll try something here Thanks

Hi, have you been successful with this problem, if so can you share how?

Posted
2 minutos atrás, irigsoft disse:

Oi, você tem tido sucesso com este problema, se então você pode compartilhar como?

We have to wait for the new version with webSocket to come out.

  • Like 1

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