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.

View File

@ -2,7 +2,8 @@
program user_client_console;
{$mode objfpc}{$H+}
{$mode objfpc}{$H+}
{ $DEFINE WST_BLOCK_TYPE}
uses
Classes, SysUtils, TypInfo, {$IFDEF WINDOWS}ActiveX,{$ENDIF}
@ -149,7 +150,7 @@ const ADDRESS_MAP : array[TTransportType] of string = (
'LIB:FileName=..\library_server\lib_server.dll;target=UserService',
//'LIB:FileName=C:\Programmes\D7\etatcivil\partages\wst\samples\library_server\lib_server.dll;target=UserService',
//'TCP:Address=172.16.82.31;Port=1234;target=UserService',
'TCP:Address=127.0.0.1;Port=1234;target=UserService',
'TCP:Address=127.0.0.1;Port=1234;target=UserService'{$IFDEF WST_BLOCK_TYPE}+';UseBlockType=True'{$ENDIF},
{$IFDEF USING_APACHE}
'http:Address=http://127.0.0.1:8080/wst/services/UserService'
{$ELSE USING_APACHE}