|
One of ASTA's design goals was "To provide a Messaging Layer that
can be used by Database Developers that are NOT socket programmers".
Both the AstaServerSocket and AstaClientSocket have easy to use
messaging calls. You can send a string or a stream with
SendCodedMessage or SendCodedStream. The AstaServerSocket takes an
extra argument of ClientSocket:TcustomWinSocket but otherwise the calls
are the same.
Here is the way the ASTAClientSocket can be used:
Procedure SendCodedMessage(Msgid:Integer;Msg:String);
Procedure SendCodedStream(MsgID: Integer; MS: TMemoryStream);
Then on the Server you would just code the
AstaserverSocket.OnCodedMessage like this:
procedure TForm1.AstaServerSocket1CodedMessage(Sender: TObject;
ClientSocket: TCustomWinSocket; MsgID: Integer; Msg: String);
begin
Case Msgid of:
1000: AstaServerSocket1.SendCodedMessage(ClientSocket,1001,'Hello back to you!');
end;
end;
When we built ASTA there were times of course that we wanted to send
other kinds of data than strings and streams so we created the
TAstaParamList. The TAstaParamList is just like a TParamList that you
are familiar with on the TQuery component but it is fully streamable.
It also can contain DataSets, any kind of binaries and even other
ParamLists.
So once we created the TAstaParamList and the call
Procedure SendCodedParamList(Msgid:Integer;Params:TAstaParamList);
We pretty much could transport anything back and forth between
servers and clients (and client to client also) easily.
But you say, in the above examples we send in one place and receive
in an event and you told us that you saved us from that.
AstaClientSockets have a call of SendGetCodedParamList which sends
a TAstaParamList and also waits until the server sends back a response.
This allows to write procedural code rather than event driven code.
Var
P1,P2: TAstaParamlist;
begin
P1 := TastaParamList.Create;
try
p1.FastAdd('Hello World');
p1.fastAdd(Now);
p1.FastAdd(4.333);
p2 := AstaClientsocket1.SendGetcodedParamList(1010,p1);
//do something with the P2 Paramlist
//that is returned from the function result
finally
p1.free;
p2.free;
end;
end;
ASTA users have thought of all kinds of ways to use ASTA messaging
from taking fairly static queries and executing and compressing them on
ASTA servers to be sent out using ASTA messaging, to controlling remote
servers, to getting back performance information form servers, to
sending faxes.
Once you have a middle tier there is a complete world that opens up
of new possibilities.
|