Early Connect


The earliest you can access an Astaserver is in the OnConnect of the AstaclientSocket. The formcreate or formshow will most probably be called before the AstaclientSocket connects to the server.

 

ASTA uses non-blocking event driven Sockets which are asyncronous by nature. You can't write procedural code. We have shielded you from this everywhere but in the Connect.

 

Move your intialization code to the OnConnect method of the AstaClientSocket as that is where you know the socket will be connected.

 

Some people do this but coding the OnConnect event is preferable

 

AstaClientSocket1.Active:=True

While not Astaclientsocket1.Active do

 Application.ProcessMessages

 

When you have an AstaClientDataSet open at design time here is what we do behind the scenes.

 

1. The AstaclientDataSet will be opened in the formcreate. The socket is not connected yet so ASTA throws it in a List and closes it.

 

2. After the AstaclientSocket connects ASTA iterates through all the AstaclientDataSets found in step #1 and opens them again.

 

3. At run time when you say AstaClientDataSet.Open ASTA goes into a wait state using AstaSmartWait to allow you to write procedural code and to shield you from the true asyncronous nature of sockets.

 

Note:Astamessaging is asyncronous also. You do a SendCodedMessage and then handle it in the OnCodedMesssage. However, we added a SendGetAstaparamList that uses AstaSmartWait to allow you to write procedural code with Asta Messaging also.

 



ASTA Overview