⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smg_clientreadthread.pas

📁 SPIG1.1.rar SPIG接口协议
💻 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,'客户端请求服务类型错误!');
         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);       //添加到网络队列中
        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次无效访问的客户端将踢出网络。
         end else I:=0;
        Exit;
      end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -