?? smg_clientreadthread.pas
字號:
unit SMG_ClientReadThread;
interface
uses
Classes, SysUtils, SP_SMG_DLL;
type
TClientRead_Thread = class(TThread)
private
RecvClient : TRecvClient;
Sck_Handle : LongInt;
procedure ClientRead;
{ Private declarations }
protected
procedure Execute; override;
public
constructor Create(Recv_Client : TRecvClient; SckHandle : LongInt; CreateSuspended: Boolean);
end;
implementation
{ Important: Methods and properties of objects in VCL or CLX can only be used
in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure TClientRead_Thread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ TClientRead_Thread }
uses SPServer,
SMG_DB;
procedure TClientRead_Thread.Execute;
begin
{ Place thread code here }
FreeOnTerminate := True;
ClientRead;
end;
constructor TClientRead_Thread.Create(Recv_Client : TRecvClient; SckHandle : LongInt; CreateSuspended: Boolean);
begin
RecvClient := Recv_Client;
Sck_Handle := SckHandle;
FreeOnTerminate := True;
inherited Create(CreateSuspended);
end;
procedure TClientRead_Thread.ClientRead;
var
Fee_Type,Fee_Value,Priority,ReportFlag,
pSPNum,pUserName,PassWord,SvcType:string;
Old_SckHandle:LongInt;
pDeliver : DeliverStr;
pReport : ReportStr;
BufferList : PSendBuffer;
Count,I:Integer;
begin
Old_SckHandle := Sck_Handle;
FillChar(pDeliver,SizeOf(pDeliver),' ');
FillChar(pReport,SizeOf(pReport),' ');
pSPNum:=string(RecvClient.SPNumber);
pUserName:=string(RecvClient.UserName);
PassWord:=string(RecvClient.PassWord);
if SearchBind(pSPNum,UserName,PassWord) then
begin
CurLogMsg(frmSGIP.TRE,pSPNum+'遠程客戶端連接本機成功!');
SvcType := string(RecvClient.SvcType);
if not SearchSvcType(pSPNum,SvcType) then
begin
CurLogMsg(frmSGIP.TRE,'客戶端請求服務(wù)類型錯誤!');
SendBuffer(Sck_Handle,pDeliver,pReport,ErrSvcType);
Exit;
end;
SvcType := ResultSvcType(pSPNum,SvcType,1);
Fee_Type := ResultSvcType(pSPNum,SvcType,2);
Fee_Value := ResultSvcType(pSPNum,SvcType,3);
Priority := ResultSvcType(pSPNum,SvcType,4);
ReportFlag:= ResultSvcType(pSPNum,SvcType,5);
AddToSckHandle(Sck_Handle,pSPNum); //添加到網(wǎng)絡(luò)隊列中
Count:= Length(RecvClient.UserNumber)div 11;
New(BufferList);
with BufferList^ do
begin
SPNumber:=pSPNum;
ChargeNumber:=RecvClient.ChargeNumber;
UserCount:=Count;
UserPhone:=RecvClient.UserNumber;
CorpID:=PChar(SPCode);
SvcType:=PChar(SvcType);
FeeType:=FeeType;
FeeValue:=FeeValue;
Given_Value:=#0;
Agent_Flag:=#0;
Mo_Flag:=#0;
Priority:=Priority;
Expire_Time:=RecvClient.ExpireTime;
Schedule_Time:=RecvClient.ScheduleTime;
Move(ReportFlag,Report_Flag,SizeOf(Report_Flag));
Tp_pid:=RecvClient.TP_Pid;
Tp_udhi:=RecvClient.TP_Udhi;
Message_Coding:=#0;
Message_Type:='0';
Message_Length:=RecvClient.MessageLen;
Message_Content:=RecvClient.MessageContent;
Reserve:=#0;
end;
BufferList.Add(Buffer);
end else
begin
CurLogMsg(frmSGIP.TRE,'遠程客戶端試圖連接本機,被拒絕!');
SendBuffer(Sck_Handle,pDeliver,pReport,AccessFial);
if Old_SckHandle = Sck_Handle then
begin
Inc(I);
if I > 3 then
DisonnectSck(Old_SckHandle);//將試圖3次無效訪問的客戶端將踢出網(wǎng)絡(luò)。
end else I:=0;
Exit;
end;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -