Mass order request

Imported from previous forum

Hi

I want to send the mass order request to the other side only after i receive the test request from the other side.

currently i am following these steps
1.Send a logon request
2.Receive the response
3.if the received response is logon i send the mass order request

Quick fix will send the response heartbeat when its received the test request from the server.
But some times there is a slight delay in sending the response heartbeat ( my mass order request goes before the response heartbeat)
how can i fix this?
please help me out