How to keep alive the socket connection ?
I mean that the user need to keep the app and the connection alive to send data to the connected devices.
I tested my code and I can see that the "AStreams_Terminated" is called also when the app is in foreground and KeepAlive(True) is called.
I mean that the user need to keep the app and the connection alive to send data to the connected devices.
B4X:
'STARTER
Sub Process_Globals
Dim WFPrinter AsSocket 'Network library
Dim AStreams AsAsyncStreams 'RandomAccessFile library
End Sub
'MAIN
Sub Activity_Resume
Starter.WFPrinter.Initialize("WFPrinter")
Starter.WFPrinter.Connect("192.168.0.87", 9100, 0)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
Starter.AStreams.Close
Starter.WFPrinter.Close
End If
End Sub
Sub WFPrinter_Connected (Successful As Boolean)
Log(Successful)
If Successful Then
Starter.AStreams.Initialize(Starter.WFPrinter.InputStream, Starter.WFPrinter.OutputStream, "AStreams")
Else
End If
End Sub
I tested my code and I can see that the "AStreams_Terminated" is called also when the app is in foreground and KeepAlive(True) is called.