sample, tcp blocktype handling

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1784 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2011-08-08 02:26:00 +00:00
parent 0a24ccf684
commit 4e6ea3a726
2 changed files with 42 additions and 5 deletions

View File

@ -13,7 +13,7 @@
program tcp_server;
{$INCLUDE wst.inc}
{ $DEFINE WST_BLOCK_TYPE}
uses
{$IFDEF FPC}
{$IFDEF UNIX}
@ -30,14 +30,45 @@ uses
server_listener ,
fpc_tcp_server,
//synapse_tcp_server,
//indy_tcp_server,
//indy_tcp_server,
user_service_intf, user_service_intf_binder, user_service_intf_imp , imp_helper,
server_service_xmlrpc;
{$IFDEF WST_BLOCK_TYPE}
type
{ TSampleBlockHandler }
TSampleBlockHandler = class(TInterfacedObject,IBlockHandler)
protected
procedure Execute(
const ABlockType : LongInt;
ARequestBlock,
AResponseBlock : TStream
);
end;
procedure TSampleBlockHandler.Execute(const ABlockType : LongInt;
ARequestBlock, AResponseBlock : TStream);
var
fs : TMemoryStream;
begin
WriteLn('Block Type = ',ABlockType);
fs := TMemoryStream.Create();
try
fs.CopyFrom(ARequestBlock,0);
fs.SaveToFile(ExpandFileName('.'+PathDelim+'request.log'));
finally
fs.Free();
end;
end;
{$ENDIF WST_BLOCK_TYPE}
var
listener : TwstListener;
{$IFDEF WST_BLOCK_TYPE}
blockHandler : IBlockHandler;
{$ENDIF WST_BLOCK_TYPE}
begin
Server_service_RegisterBinaryFormat();
Server_service_RegisterSoapFormat();
@ -56,6 +87,11 @@ begin
//listener := TwstSynapseTcpListener.Create();
//listener := TwstIndyTcpListener.Create();
listener := TwstFPCTcpListener.Create();
{$IFDEF WST_BLOCK_TYPE}
blockHandler := TSampleBlockHandler.Create() as IBlockHandler;
TwstBaseTcpListener(listener).UnknownBlockHandler := blockHandler;
TwstBaseTcpListener(listener).Options := [tloHandleBlockType];
{$ENDIF WST_BLOCK_TYPE}
listener.Start();
ReadLn;
end.