dont make net request if process not active

This commit is contained in:
April Ayres-Griffiths 2019-04-13 11:49:49 +10:00
parent 2af364c09a
commit c708f41130
6 changed files with 51 additions and 3 deletions

View File

@ -1,7 +1,7 @@
object GUIForm: TGUIForm
Left = 2260
Left = 2255
Height = 668
Top = 311
Top = 312
Width = 1014
AlphaBlendValue = 128
Caption = 'microM8 GUI'

View File

@ -469,6 +469,7 @@ type
procedure UpdateColorMode;
procedure UpdateTintMode;
function SimpleGet(url:String): string;
function SimpleGetInt(url:String): integer;
procedure LaunchDisk(disk: string);
procedure LaunchCommand(dialect: string; path: string; command: string);
procedure SimpleFormPost(url: String; body: string; var resp: TStringStream);
@ -914,7 +915,7 @@ end;
procedure TGUIForm.miDisk2WPToggleClick(Sender: TObject);
begin
SimpleGet( baseUrl + '/api/control/hardware/disk/wp/1/toggle' );
end;
procedure TGUIForm.miDiskMenuWPClick(Sender: TObject);
@ -2046,6 +2047,10 @@ end;
function TGUIForm.SimpleGet(url:string): string;
begin
result := '0';
if not MicroM8Process.Active then
exit;
try
result := self.httpc.Get(url)
except
@ -2055,6 +2060,22 @@ begin
end;
end;
function TGUIForm.SimpleGetInt(url:string): integer;
begin
result := 0;
if not MicroM8Process.Active then
exit;
try
result := StrToInt(self.httpc.Get(url))
except
on e: Exception do begin
// nothing much
end;
end;
end;
procedure TGUIForm.SimpleGetStream(url:string; var S: TMemoryStream);
begin
try

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -469,6 +469,7 @@ type
procedure UpdateColorMode;
procedure UpdateTintMode;
function SimpleGet(url:String): string;
function SimpleGetInt(url:String): integer;
procedure LaunchDisk(disk: string);
procedure LaunchCommand(dialect: string; path: string; command: string);
procedure SimpleFormPost(url: String; body: string; var resp: TStringStream);
@ -2046,6 +2047,10 @@ end;
function TGUIForm.SimpleGet(url:string): string;
begin
result := '0';
if not MicroM8Process.Active then
exit;
try
result := self.httpc.Get(url)
except
@ -2055,8 +2060,28 @@ begin
end;
end;
function TGUIForm.SimpleGetInt(url:string): integer;
begin
result := 0;
if not MicroM8Process.Active then
exit;
try
result := StrToInt(self.httpc.Get(url))
except
on e: Exception do begin
// nothing much
end;
end;
end;
procedure TGUIForm.SimpleGetStream(url:string; var S: TMemoryStream);
begin
if not MicroM8Process.Active then
exit;
try
self.httpc.Get(url, S)
except
@ -2069,6 +2094,8 @@ end;
procedure TGUIForm.SimpleFormPost( url: string; body: string; var resp: TStringStream );
begin
if not MicroM8Process.Active then
exit;
try
self.httpc.SimpleFormPost(url,body,resp)
except