rejetto forum
Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Mars on April 08, 2009, 12:13:08 AM
-
main.pas
function startServer():boolean;
.......
result:=TRUE;
runeventscript('startserver'); //add by mars
end; // startServer
procedure stopServer();
begin
if assigned(srv) then
begin
runeventscript('stopserver'); //add by mars
srv.stop();
end;
end;
hfs.events
For help on how to use this file please refer http://www.rejetto.com/wiki/?title=HFS:_Event_scripts
[startserver]
{.add to log|Hfs entered phase of activity.}
[stopserver]
{.add to log|Hfs entered phase of sleep.}
Here we are, it can be of use to the other more interesting features as the macro {.set ini.} ;)
-
startserver is like "to start the server".
in english a better description of the event is "server start"
would you agree at renaming the events [server start] and [server stop] ?
-
you can choice the names, but those events are not the same as [start] and [quit], do not confuse ;)
-
i know, i know.
i told you so that we don't use different names.
ah, i didn't put them in the startserver() and stopserver(), but in httpEvent() HE_OPEN / HE_CLOSE.
more reliable.
-
case event of
HE_CANT_OPEN_FILE: data.error:='Can''t open file';
HE_OPEN:
begin
mainfrm.add2log('SERVER OPEN');
runEventScript('HE_OPEN');
end;
HE_CLOSE:
begin
mainfrm.add2log('SERVER CLOSE');
runEventScript('HE_CLOSE');
end;
HE_REQUESTING:
begin
runEventScript('HE_REQUESTING');
end;
HE_REQUESTED:
begin
runEventScript('HE_REQUESTED');
end;
HE_REPLIED:
begin
runEventScript('HE_REPLIED');
end;
HE_LAST_BYTE_DONE:
begin
runEventScript('request completed');
end;
.....
If to use as place httpEvent () works with the events of type
[HE_REQUESTING]
{.add to log|[HE_REQUESTING].}
[HE_REQUESTED]
{.add to log|[HE_REQUESTED].}
[HE_REPLIED]
{.add to log|[HE_REPLIED].}
it is not the case of both last ones
[HE_OPEN]
{.add to log|[HE_OPEN].}
[HE_CLOSE]
{.add to log|[HE_CLOSE].}
and furthermore that was created a dysfunction with the use of the touch F4
The only completely functional method thus remains at the moment this one
main.pas
function startServer():boolean;
.......
result:=TRUE;
runeventscript('server start'); //add by mars
end; // startServer
procedure stopServer();
begin
if assigned(srv) then
begin
runeventscript('server stop'); //add by mars
srv.stop();
end;
end;
hfs.events
For help on how to use this file please refer http://www.rejetto.com/wiki/?title=HFS:_Event_scripts
[server start]
{.add to log|Hfs entered phase of activity.}
[server stop]
{.add to log|Hfs entered phase of sleep.}
-
it's a bug.
this line
> if assigned(data.f) then // a file has been uploaded
is accessing data field even if data is NIL.
same as this
> md.f:=data.lastFile;
fixed in next build.
thanks for reporting ;)
-
i am creating a new topic with bugs reported with uploaded files, inside him is solutions.
http://www.rejetto.com/forum/index.php?topic=6842.0
restricted bug with 'server start/stop'
After some checks of last minute, it seems, that only the use of 'runeventscript('server start/stop')', raises problems
In the compilation, it was not the good procedure which was called, but her twin sister. It is for it that the event did not work. Rejetto, you should not have named the procedures with the same name
HE_OPEN:
begin
startBtn.Hide();
updateUrlBox();
// this happens when the server is switched on programmatically
usingFreePort:= port='';
updatePortBtn();
MAIN.runeventscript('server start'); // mod by mars
end;
HE_CLOSE:
begin
startBtn.show();
updatePortBtn();
updateUrlBox();
MAIN.runeventscript('server stop'); // mod by mars
end;
found the origin of bug with this modif F4 works but the two events are not running
hslib.pas
procedure ThttpSrv.stop();
begin
if assigned(sock) then
try
sock.Close() ;
notify(HE_CLOSE, NIL)
except end;
end;
procedure ThttpSrv.connected(Sender: TObject; Error: Word);
begin if error=0 then ThttpConn.create(self) end;
procedure ThttpSrv.disconnected(Sender: TObject; Error: Word);
begin
// notify(HE_CLOSE, NIL)
end;
with the above codes all is ok, or take my solution at the first post.