mysticbbs/mystic/mis_client_http.pas

106 lines
2.0 KiB
ObjectPascal
Raw Normal View History

2012-02-14 08:07:26 -08:00
Unit MIS_Client_HTTP;
2012-06-30 17:23:39 -07:00
{$I M_OPS.PAS}
2012-02-13 16:53:02 -08:00
Interface
Uses
2012-06-30 17:23:39 -07:00
MD5,
Classes,
2012-02-13 16:53:02 -08:00
SysUtils,
m_Strings,
m_FileIO,
m_Socket_Class,
m_DateTime,
MIS_Server,
MIS_NodeData,
2012-06-30 17:23:39 -07:00
MIS_Common,
BBS_MsgBase_ABS,
BBS_MsgBase_JAM,
BBS_MsgBase_Squish;
2012-02-13 16:53:02 -08:00
2012-06-30 17:23:39 -07:00
Function CreateHTTP (Owner: TServerManager; Config: RecConfig; ND: TNodeData; CliSock: TSocketClass) : TServerClient;
2012-02-13 16:53:02 -08:00
Type
2012-06-30 17:23:39 -07:00
THTTPServer = Class(TServerClient)
Server : TServerManager;
UserName : String[30];
LoggedIn : Boolean;
GotQuit : Boolean;
Cmd : String;
Data : String;
2012-02-13 16:53:02 -08:00
Constructor Create (Owner: TServerManager; CliSock: TSocketClass);
Procedure Execute; Override;
Destructor Destroy; Override;
Procedure ResetSession;
End;
Implementation
2012-06-30 17:23:39 -07:00
Function CreateHTTP (Owner: TServerManager; Config: RecConfig; ND: TNodeData; CliSock: TSocketClass) : TServerClient;
2012-02-13 16:53:02 -08:00
Begin
2012-06-30 17:23:39 -07:00
Result := THTTPServer.Create(Owner, CliSock);
2012-02-13 16:53:02 -08:00
End;
2012-06-30 17:23:39 -07:00
Constructor THTTPServer.Create (Owner: TServerManager; CliSock: TSocketClass);
2012-02-13 16:53:02 -08:00
Begin
Inherited Create(Owner, CliSock);
Server := Owner;
End;
2012-06-30 17:23:39 -07:00
Procedure THTTPServer.ResetSession;
Var
Count : LongInt;
2012-02-13 16:53:02 -08:00
Begin
2012-06-30 17:23:39 -07:00
LoggedIn := False;
GotQuit := False;
2012-02-13 16:53:02 -08:00
End;
2012-06-30 17:23:39 -07:00
Procedure THTTPServer.Execute;
2012-02-13 16:53:02 -08:00
Var
Str : String;
Begin
ResetSession;
2012-06-30 17:23:39 -07:00
// Client.WriteLine(re_Greeting);
2012-02-13 16:53:02 -08:00
Repeat
2012-06-30 17:23:39 -07:00
If Client.WaitForData(60 * 1000) = 0 Then Break;
2012-02-13 16:53:02 -08:00
If Terminated Then Exit;
If Client.ReadLine(Str) = -1 Then Exit;
Cmd := strUpper(strWordGet(1, Str, ' '));
If Pos(' ', Str) > 0 Then
Data := strStripB(Copy(Str, Pos(' ', Str) + 1, Length(Str)), ' ')
Else
Data := '';
2012-06-30 17:23:39 -07:00
If Cmd = 'QUIT' Then Begin
GotQuit := True;
Break;
End Else
2012-02-13 16:53:02 -08:00
Client.WriteLine(re_UnknownCommand);
Until Terminated;
2012-06-30 17:23:39 -07:00
If GotQuit Then Begin
Client.WriteLine(re_Goodbye);
Server.Server.Status (User.Handle + ' logged out');
End;
2012-02-13 16:53:02 -08:00
End;
2012-06-30 17:23:39 -07:00
Destructor THTTPServer.Destroy;
2012-02-13 16:53:02 -08:00
Begin
2012-06-30 17:23:39 -07:00
ResetSession;
2012-02-13 16:53:02 -08:00
Inherited Destroy;
End;
End.