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

📄 clientinterpreter.pas

📁 一般的数据库管理系统 uses Classes, SConnectEx, TltConst, ExtCtrls, MMSystem, Types, windows, TltLogic , Sy
💻 PAS
字号:
unit ClientInterpreter;
{Tlt logic layer}
interface
uses Classes, SConnect, TltConst, ExtCtrls;
type
  TrltClientInterpreter = class(TDataBlockInterpreter)
    function DoCustomAction(Action: Integer; const Data: IDataBlock): Boolean; override;
  public
    {Receiving Calls}
    procedure DoGetServerInfo(const Data: IDataBlock);
    procedure DoGetCurrentRoundNo(const Data: IDataBlock);
    procedure DoSetCountDown(const Data: IDataBlock);
    {Sending Calls}
    function CallGetServerInfo : TServerInfo;
    function CallGetCurrentRoundNo: integer;
    {Sendto Client}
    procedure CallSetCountDown;

  end;




implementation
uses ScktCnst, rltClient;


{ TTltInterpreter }

function TrltClientInterpreter.CallGetServerInfo: TServerInfo;
var
  Data: IDataBlock;
  Size : integer;
  s : TServerInfo;
begin
  Data := TDataBlock.Create as IDataBlock;
  Data.Signature := CallSig or asGetServerInfo;
  Data := FSendDataBlock.Send(Data, True);
  Data.Read(size, sizeof(size));
  Data.Read(s,Size);
  Result := s;
//  Result := ReadVariant(Flags, Data);
end;

function TrltClientInterpreter.CallGetCurrentRoundNo: integer;
var
  Data: IDataBlock;
  Size : integer;
  s : integer;
begin
  Data := TDataBlock.Create as IDataBlock;
  Data.Signature := CallSig or asGetCurrentRoundNo;
  Data := FSendDataBlock.Send(Data, True);
  Data.Read(size, sizeof(size));
  Data.Read(s,Size);
  Result := s;
//  Result := ReadVariant(Flags, Data);
end;


function TrltClientInterpreter.DoCustomAction(Action: Integer;
  const Data: IDataBlock): Boolean; 
begin
  case (Action and asMask) of
    asGetServerInfo: DoGetServerInfo(Data);
    asGetCurrentRoundNo : DoGetCurrentRoundNo(Data);

    //client
    asSetCountDown : DoSetCountDown(Data);
  else
    Result := false;
  end;
end;

procedure TrltClientInterpreter.DoGetServerInfo(const Data: IDataBlock);
var
  ServerInfo : TServerInfo;
  VarSize : integer;
begin
  Data.Clear;
  try
    ServerInfo.ServerVer :='1.0';
  finally
  end;
  VarSize := sizeof(ServerInfo);
  Data.Write(VarSize, sizeof(integer));
  Data.Write(ServerInfo, VarSize);
  Data.Signature := ResultSig or asGetServers;
  FSendDataBlock.Send(Data, False);
end;

procedure TrltClientInterpreter.DoGetCurrentRoundNo(const Data: IDataBlock);
var
  VarSize : integer;
begin
  Data.Clear;
  WriteVariant(rltManager.CurrentRoundNo, Data);
  Data.Signature := ResultSig or asGetServers;
  FSendDataBlock.Send(Data, False);
end;


procedure TrltClientInterpreter.CallSetCountDown;
var
  Data: IDataBlock;
  Size : integer;
  s : integer;
begin
  Data := TDataBlock.Create as IDataBlock;
  WriteVariant(rltManager.CountDown, Data);
  Data.Signature := CallSig or asSetCountDown;
  Data := FSendDataBlock.Send(Data, True);
end;

procedure TrltClientInterpreter.DoSetCountDown(const Data: IDataBlock);
var
  VarSize : integer;
  VarFlag : TVarFlag;
begin

  // Client. := ReadVariant(VarFlag, Data);
end;

end.

⌨️ 快捷键说明

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