@@ -74,12 +74,19 @@ def send(request):
7474 "OrderCancelRequest" : OrderCancelRequest ,
7575 "OrderCancelReplaceRequest" : OrderCancelReplaceRequest }
7676
77+ testReqId = 0
78+
7779def executeUserCommand ():
7880 try :
7981 print ("\n " )
80- userInput = inputimeout ("Command (ex: Help): " , timeout = 30 )
82+ userInput = inputimeout ("Command (ex: Help): " , timeout = int ( config [ "HeartBeat" ]) )
8183 except TimeoutOccurred :
82- print ("Command Input Timeout" )
84+ print ("Timeout, sending TestRequest (Connection will be dropped if you are not logged in yet)" )
85+ testRequest = TestRequest (config )
86+ global testReqId
87+ testReqId += 1
88+ testRequest .TestReqID = testReqId
89+ send (testRequest )
8390 reactor .callLater (3 , callable = executeUserCommand )
8491 return
8592 if userInput .lower () == "help" :
@@ -101,12 +108,19 @@ def executeUserCommand():
101108 request = commands [command ](config )
102109 setParameters (request , ** parameters )
103110 send (request )
111+ print ("If response message not arrived keep pressing 'Enter'" )
104112 else :
105- print ("Invalid Command: " , userInput )
113+ if userInput != "" :
114+ print ("Invalid Command: " , userInput )
106115 reactor .callLater (3 , callable = executeUserCommand )
107116
108117def onMessageReceived (client , responseMessage ): # Callback for receiving all messages
109118 print ("\n Received: " , responseMessage .getMessage ().replace ("" , "|" ))
119+ if responseMessage .getFieldValue (35 ) == "1" :
120+ print ("TestRequest received, sending back Heartbeat" )
121+ heartbeat = Heartbeat (config )
122+ heartbeat .TestReqID = responseMessage .getFieldValue (112 )
123+ send (heartbeat )
110124 reactor .callLater (3 , callable = executeUserCommand )
111125
112126def disconnected (client , reason ): # Callback for client disconnection
0 commit comments